Hi,
My goal is this: 1 workflow field shared on 2 content types, at certain states, additional information added to the transition form & put into node fields. Also at some point it needs to switch from one node to the other. I imagine this is doable in code, but the first hangup is one i didn't expect. I am rendering the transition form in a custom block like this:
function mymodule_block_contents()
{
...
if ($current = workflow_node_current_state($n))
{
$bundle = $node->type;
$field_name = 'field_my_workflow';
$workflow = workflow_get_workflows_by_type($bundle, 'node');
$field = _workflow_info_field($field_name, $workflow);
$entity_type = 'node';
$instance = field_info_instance($entity_type, $field_name, $bundle);
$form = array();
$form_state = array();
$f = drupal_get_form('workflow_transition_form', $field, $instance, $entity_type, $n);
//hide the comment box
$f['workflow']['workflow_comment']['#access'] = FALSE;
//hide the button for the current state
$f['workflow']['submit_sid'][$current]['#access'] = FALSE;
$f = drupal_render($f);
return $f;
}
}
and want to add elements above or use form alter to add the elements and additional submit handler.
...
function mymodule_form_alter($form, $form_state, $form_id)
{
if($form_id == 'workflow_transition_form')
{
$form['myelement'] = ...
}
}
But the custom element never shows up in the form, whether i put myelement as $form['myelement'], $form['workflow']['myelement'], or $form['workflow']['workflow_sid'][$sid]['myelement'], and it doesn't matter whether i do it in form_alter or in the original block_contents. Also no effect when i add a function to the #submit arrays. It never gets called.
Any ideas? I would like to access the submitted values in either hook_workflow or a custom submit handler.
Thanks much.
Comments
Comment #1
davery CreditAttribution: davery commentedComment #2
davery CreditAttribution: davery commentedComment #3
johnvYou might want to check out the file workflow.pages.inc, since that's where the form (Widget) programmatically is added to the Workflow History Tab.
You might also create a block display using Views. Then add the Workflow Field (assuming you use that) to the block, and add an argument to filter the correct node.
Comment #4
johnvAnd the workflow.api.php file gives documentation, too.
Comment #5
johnvDid you manage to solve this?
Do you have anything to share from your findings?
Comment #6
johnvClosing this for lack of response.
ITMT, the file workflow.api.php contains some example code. See also #318325: [Meta] Display/hide/require the Widget subfields based on State/Role which contains info about the usable hooks.