Adding Additional Field in Workflow

Events happening in the community are now at Drupal community events on www.drupal.org.
mullman's picture

I originally setup a CCK form for authenticated users who submit a request and identify a supervisor's email address which is then used by workflow and actions to submit it to that address. The supervisor is then asked to visit the node and approve or deny the request. I originally set it up with content permissions to display certain fields accordingly (only supervisors would be able to edit the "manager's email" field), however, in this situation we have no way of separating general authenticated users from supervisors. As a result, since authenticated users are not allowed to edit the node supervisors are not able to identify their manager's email address within the CCK form in order to send it up the chain of command.

My solution was to attempt to use hook_form_alter() on the workflow form to add an additional field ahead of the workflow comments so a supervisor could identify their manager and continue the flow up their chain of command. Unfortunately, I'm running into some problems with this. Is this the right approach? If so, could someone point me to some documentation on how to add a field to a workflow form?

Comments

I figured it out

mullman's picture

I apologize for prematurely submitting my initial message. I was able to accomplish it with the following code:

function MODULENAME_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'workflow_tab_form' && isset($form['workflow']['MYWORKFLOWNAME'])) {
$form['workflow']['workflow_comment'] = array(
'#type' => 'textarea',
'#title' => t('Explain why you approve or deny this request'),
'#description' => '',
'#default_value' => '',
'#rows' => 2,
);
$form['workflow']['your_supervisor_email'] = array(
'#type' => 'textfield',
'#title' => t('Email Address of Your Supervisor'),
'#description' => t('Your supervisor will be emailed information about this request to continue the process. Be sure to spell it correctly.'),
'#default_value' => '',
'#weight' => 1,
);
}

return $form;
}

Great idea

mlowkwai's picture

Mullman, i like your idea! i m a beginer, can advise me how to put this in my drupal website? Very much appreaciate that.

How do you use your custom

aze2010's picture

How do you use your custom field in rules/actions?

Thank you in advanced

Workflow

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: