I have workflow installed and want to add a file upload field from an existing node to the workflow form (the same node I'm pushing through workflow). Here is how I attached the field to the workflow form:
$tmpform = array(); $tmpform_state = array(); $node = node_load($form['node']['#value']->nid); field_attach_form('node', $node, $tmpform, $tmpform_state); $workflow_state = $node->workflow; // File upload field $form['field_anr_upload_invoice'] = $tmpform['field_anr_upload_invoice']; $form_state['field']['field_anr_upload_invoice'] = $tmpform_state['field']['field_anr_upload_invoice'];
I've added text fields, taxonomy fields, etc and I can run them through validation and submit no problem using this same method and this is pretty much all I had to do but I run into a problem (I think) with ajax. The upload field will display but when I "Choose file" and click "Upload" I get an ajax error.
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'workflow_tab_form' not found or invalid function name in drupal_retrieve_form() (line 799 of DIR/www/includes/form.inc). Notice: Undefined index: node in combine_forms_form_alter() (line 16 of DIR/www/sites/all/modules/custom/combine_forms/combine_forms.module). Notice: Trying to get property of non-object in combine_forms_form_alter() (line 16 of DIR/www/sites/all/modules/custom/combine_forms/combine_forms.module). EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7710 of DIR/www/includes/common.inc).