Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I don't understand the 'getFieldNames()' function in the workflow tasks
I've been studying the workflow task in the development wiki, and the suggested github commit on adding tags, but I don't understand the 'getFieldNames' method. It simply returns an array (are the values database columns in the tasks table?), and later on they get cheched on as if they were class attributes. Is this some magic function in the system that checks if a particular entry in the database is there or something? Something that is automatically invoked when the workflow starts?
This is special functionality that the workflow tasks give you. Simply defining that array of variables makes them available to your task. Once you add the variable name to the array it will be saved in the database when saving the task and retrieved automatically for it to be read when executing the task.

The idea is that your task will need variables to permit the user to configure it and then when it is executed they will be read so the task can perform whatever it has to do. The workflow system takes care of the dirty details for you, just define the array and the variables will be magically saved and retrieved.

For example, in
The task defines three variables:
'listoftags': comma separated list of labels
'addrel': boolean to indicate if the task should add or remove the labels
'forallusers': boolean to indicate if the action will apply to all users or just the current user

once that is defined you can create an form with three widgets, one for each variable with those exact names like here:

and the variables will be saved and then retrieved on execution
As you were replying, I was taking another look at the smarty template and saw a connection. I will take another look at the files on github and try to understand the relation. But I was correct in assuming this function is 'magic' and enables you to very simply create and store values.

Okay, I've been playing with the workflow task and I think I understand:

The Smarty TPL file and the task Class work together:the TPL file sets some input fields with name attributes, and the Class collects these via the function 'getFieldNames()'. The task can then perform certain choices based on the selection of those inputs. At the same time, when editing a task, the smarty '$task->addrel' gets previously set task fields so that when you edit a task it is set the way you left it last.

Is that a correct summary of what's going on?

Forum Jump:

Users browsing this thread: 1 Guest(s)