User login

Merging forms for usability: creating nodereference or organic groups nodes within a node

UPDATE: Agaric did manage to do this. The working code is in our custom wsf_action module used on wsf2008.net. Some related notes are as follows:

http://agaricdesign.com/note/getting-subform-show-correctly
http://agaricdesign.com/note/skip-validation-form-element-drupal
http://agaricdesign.com/note/do-not-show-group-adding-subform-when-adding-action-existing-group
http://agaricdesign.com/note/hiding-extra-submit-and-preview-buttons-subforms

And I know why the usernode was getting updated-- the maximum population of nodes for this user was set, and so it was keeping count on the usernode.

Had to turn off the workflow-ng workflow that made an action group go to an action to get the drupal_submit_form, as properly called using Subform's subform_element_call, to not cut out.

// $redirect = drupal_submit_form('action_group_node_form', $subform);
$redirect = subform_element_call('drupal_submit_form', $subform['#post']['form_id'], $subform);

This little part was key:
// wow, keeping this is what makes sure it's called later!
        $form['#submit']['node_form_submit'] = array();

That is, setting that at a lower spot in the form, ensures it is called after the subform is processed and not before.

And the biggest piece of hackery:

// this couldn't get the nid over to the form that is used to submit the action node
        global $form;
        $form['og_nodeapi']['visible']['og_groups'] = array(
          '#type' => 'value',
          '#value' => $newnid,
        );       
$form['testfirst'] = array('#type' => 'markup', '#value' => 'I am here first.');
$form_values['test'] = array('#type' => 'markup', '#value' => 'I am here.');
// but $form with *these values only* was available to my implementation of hook_nodeapi !!!

So we just declared as a global variable the nid obtained from the subform_element-derived wsf_action_addnid_submit function (the aaa_ prefix was a failed attempt to get it to be called first), and then in the nodeapi implementation for saving action nodes we called that global variable and used it in an organic group function for connecting a node to an organic group:

<pre>
function wsf_action_nodeapi(&$node, $op) {
  if ($node->type == 'action') {
    switch ($op) {
      case 'insert':
        global $wsf_action_global_pass_hack_nid;
        $node->og_groups = array($wsf_action_global_pass_hack_nid);
        og_save_ancestry($node);
        break;
    } 
  }
}
</pre>

//END UPDATE

This was way harder to find than it should have been, Agaric hope our finally successful attempt to find it going through every possible way to say add a two nodes at once, the second relating to the first, helps others to the holy grail (currently under maintenance) --

http://drupal.org/project/addnode

The addnode module is a widget to be used with the nodereference CCK field type. It allows the user to either select items in a list (in the normal way) or create new items in a form on the same page.

And in fact – although the author of the subform element says it
does not allow passing an nid to the main form – the addnode module uses subform_element heavily to work its magic.

Possibly related:

Creating custom CCK widgets
http://openconcept.ca/node/543

Agaric is focusing on this function to rip off:

/**
* Called as a main form submit handler. It submits the subforms and gets the nids then puts them into
* the main node.
*/
function addnode_addnids_submit($form_id, &$form_values)
{
   //copied from subform_element_submit, allows us to get hold of the redirects and get the nids from them
  global $subforms;
  if (isset($subforms)) {
    foreach ($subforms as $key => $subform) {
      if (!isset($subform['#submitted'])) {
        $subforms[$key]['#submitted'] = TRUE;
        $redirect = subform_element_call('drupal_submit_form', $subform['#post']['form_id'], $subform);
        $fieldname = $subform['#fieldname'];
        $split = explode("/", $redirect);
        $newnid = $split[1];
        //unset the current array, and replace it with a new array.
        //note that as multiselect is currently set, this is an array
        // @todo allow multi/single select!!
        unset($form_values[$fieldname]['nids']);
        $form_values[$fieldname]['nids'] = array ( $newnid => $newnid );
      }
    }
    return $redirect;
  }
}

The rip off of addnode didn't work, with these questions:

Why did the group stuff run second?

Why is all the data thrown in #post on every damn element?

Why didn't my 'nid ' drupal message run? subform_element_call seems unable to hold and capture drupal_submit_form, nothing below it gets called.

Why is it doing something that updates my usernode each time?

Here's all the code for the curious:

/*
* Implementation of hook_form_alter()
*
*/
function wsf_action_form_alter($form_id, &$form) {
// drupal_set_message("Form ID: " . $form_id);
// drupal_set_message('<pre>' . print_r($form, TRUE) . '</pre>');
  switch ($form_id) {  // not $form['#id']
    // case 'node-form':  // this is needed
    // NO BREAK - intentional
    // case 'user_register':   - handled by form theming function now I think
      // $form['profile']['form']['#profile_node_form']['body_filter']['body']['#rows'] = 5;
      // $form['profile']['form']['body_filter']['body']['#rows'] = 5;
      // $form['profile']['#collapsible'] = 0;
    case 'profile_node_form':
      // $form['log']['#type'] = 'hidden';
      $form['body_filter']['body']['#rows'] = 5;
      break;
    case 'action_group_node_form':
      // stuff to do in both cases, for new groups or on editing form
      unset($form['i18n']['language']['#description']);
      // don't offer locale choice, we'll set it from i18n language
      unset($form['locale']);
      if (!$form['nid']['#value']) {  // creating a new action group
        $form['og_selective'] = array(
          '#type' => 'value',
          '#value' => 0, // open - subscription requests are accepted
        );       
        // multilingual settings will inherit from the action
        // for reference: [i18n][language][#type] & [#value]
        unset($form['i18n']);
        $form['title']['#title'] = t('Name for your group');
      }
      break;
    case 'action_node_form':
      unset($form['i18n']['language']['#description']);
      $form['i18n_status'] = array(
        '#type' => 'value',
        '#value' => 1, // Source content (to be translated)
      );
      if (!$form['nid']['#value']) {  // creating a new action
        $form['body_filter']['body']['#rows'] = 10;
        // remove group choice, we'll pass this in directly
        // for reference: [og_nodeapi][visible][og_groups][#type] & [#value]
        unset($form['og_nodeapi']);
        $form['subscriptions'] = array();
        $form['subscriptions']['subscriptions_subscribe'] = array(
          '#type' => 'value',
          '#value' => 1,
        );
        // the subform!
        $node = $form['#node'];
        $form['action_group'] = array(
          '#type' => 'subform',
          '#id' => 'action_group_node_form',
          '#arguments' => array(array(
            'uid' => $node->uid,
            'type' => 'action_group',
          )),
          '#after_build' => array(
            'subform_element_build_subform',
            'wsf_action_fix_subform',
          ),
          '#data_separation' => TRUE,
        );
        // we have to get out of validation for an associated group somehow
        $form['#validate'] = array();
        //add submit handlers:
          //Add the nids of the newly created sub-nodes to the node
        $form['#submit']['aaa_wsf_action_addnid_submit'] = array();
          //the subform element submit handler
        $form['#submit']['subform_element_submit'] = array();
          //the handler for the base node (todo: Is this still necessary, I think subform_element might do this)  ben-agaric: it does.
        // $form['#submit']['node_form_submit'] = array();
      }
      break;
  }
}

/**
* This is called as an #after_build function for each subform.
*It 1) Disables the subform's validation etc if it's unused
*   2) Removes the subform's buttons.
*/
function wsf_action_fix_subform($form_element, &$form_values)
{
//  $form_element['#form'] = array_merge($form_element['#form'], og_group_form($node));

  //Remove submit and preview buttons from the subform.
  $form_element['#form']['submit']['#attributes'] = array(
    'style' => 'height:0px; visibility:hidden;',
  );
  $form_element['#form']['preview']['#attributes'] = array(
    'style' => 'height:0px; visibility:hidden;',
  );

  return $form_element;
}

/**
* Called as a main form submit handler. It submits the subforms and gets the nids then puts them into
* the main node.
*/
function aaa_wsf_action_addnid_submit($form_id, &$form_values)
{
drupal_set_message('in wsf_action_addnid_submit');
   //copied from subform_element_submit, allows us to get hold of the redirects and get the nids from them
  global $subforms;
  if (isset($subforms)) {
    foreach ($subforms as $key => $subform) {
drupal_set_message('<pre>' . print_r($subform, TRUE) . '</pre>'); 
      if (!isset($subform['#submitted'])) {
        $subforms[$key]['#submitted'] = TRUE;
drupal_set_message("I'm here.");       
        $redirect = subform_element_call('drupal_submit_form', $subform['#post']['form_id'], $subform);
drupal_set_message("I'm not.");       
        // $fieldname = $subform['#fieldname'];
        $split = explode("/", $redirect);
        $newnid = $split[1];
drupal_set_message('nid ' . $newnid);       
        //unset the current array, and replace it with a new array.
        //note that as multiselect is currently set, this is an array
        // @todo allow multi/single select!!
        // unset($form_values[$fieldname]['nids']);
        $form_values['og_nodeapi']['visible']['og_groups'] = array(
          '#type' => 'value',
          '#value' => $newnid,
        );
      }
    }
    return $redirect;
  }
}

Here's debugging stuff.
# Your Action has been created.
# in wsf_action_addnid_submit
#

Array
(
[0] => Array
(
[#id] => node-form
[nid] => Array
(
[#type] => value
[#value] =>
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => nid
)

[#weight] => 0
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => nid
[#id] => edit-nid
[#sorted] => 1
)

[vid] => Array
(
[#type] => value
[#value] =>
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => vid
)

[#weight] => 0.001
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => vid
[#id] => edit-vid
[#sorted] => 1
)

[uid] => Array
(
[#type] => value
[#value] => 3
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => uid
)

[#weight] => 0.002
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => uid
[#id] => edit-uid
[#sorted] => 1
)

[created] => Array
(
[#type] => value
[#value] =>
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => created
)

[#weight] => 0.003
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => created
[#id] => edit-created
[#sorted] => 1
)

[type] => Array
(
[#type] => value
[#value] => action_group
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => type
)

[#weight] => 0.004
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => type
[#id] => edit-type
[#sorted] => 1
)

[changed] => Array
(
[#type] => hidden
[#default_value] =>
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => changed
)

[#weight] => 0.005
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => changed
[#id] => edit-changed
[#value] =>
[#needs_validation] => 1
[#sorted] => 1
)

[title] => Array
(
[#type] => textfield
[#title] => Name for your group
[#required] => 1
[#default_value] =>
[#weight] => -5
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => title
)

[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#input] => 1
[#size] => 60
[#maxlength] => 128
[#autocomplete_path] =>
[#name] => title
[#id] => edit-title
[#value] => Joined form action group
[#needs_validation] => 1
[#sorted] => 1
)

[#node] => stdClass Object
(
[uid] => 3
[type] => action_group
[comment] => 0
[status] => 1
[promote] =>
[sticky] =>
[revision] => 1
)

[log] => Array
(
[#type] => hidden
[#title] => Log message
[#rows] => 2
[#weight] => 20
[#description] => An explanation of the additions or updates being made to help other authors understand your motivations.
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => log
)

[#processed] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => log
[#id] => edit-log
[#value] =>
[#needs_validation] => 1
[#sorted] => 1
)

[author] => Array
(
[#type] => fieldset
[#access] =>
[#title] => Authoring information
[#collapsible] => 1
[#collapsed] => 1
[#weight] => 20
[name] => Array
(
[#type] => textfield
[#title] => Group manager
[#maxlength] => 60
[#autocomplete_path] => user/autocomplete
[#default_value] =>
[#weight] => -1
[#description] => Leave blank for Visitor.
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#parents] => Array
(
[0] => name
)

[#processed] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#size] => 60
[#name] => name
[#id] => edit-name
[#value] =>
[#sorted] => 1
)

[date] => Array
(
[#type] => textfield
[#title] => Authored on
[#maxlength] => 25
[#description] => Format: . Leave blank to use the time of form submission.
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#parents] => Array
(
[0] => date
)

[#weight] => 0.001
[#processed] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#size] => 60
[#autocomplete_path] =>
[#name] => date
[#id] => edit-date
[#value] =>
[#sorted] => 1
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => author
)

[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
)

[options] => Array
(
[#type] => fieldset
[#access] =>
[#title] => Publishing options
[#collapsible] => 1
[#collapsed] => 1
[#weight] => 25
[status] => Array
(
[#type] => checkbox
[#title] => Published
[#default_value] => 1
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#parents] => Array
(
[0] => status
)

[#weight] => 0
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#return_value] => 1
[#name] => status
[#id] => edit-status
[#value] => 1
[#sorted] => 1
)

[promote] => Array
(
[#type] => checkbox
[#title] => Promoted to front page
[#default_value] =>
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#parents] => Array
(
[0] => promote
)

[#weight] => 0.001
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#return_value] => 1
[#name] => promote
[#id] => edit-promote
[#value] =>
[#sorted] => 1
)

[sticky] => Array
(
[#type] => checkbox
[#title] => Sticky at top of group home page and other lists
[#default_value] =>
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#parents] => Array
(
[0] => sticky
)

[#weight] => 0.002
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#return_value] => 1
[#name] => sticky
[#id] => edit-sticky
[#value] =>
[#sorted] => 1
)

[revision] => Array
(
[#type] => checkbox
[#title] => Create new revision
[#default_value] => 1
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#parents] => Array
(
[0] => revision
)

[#weight] => 0.003
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#return_value] => 1
[#name] => revision
[#id] => edit-revision
[#value] => 1
[#sorted] => 1
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => options
)

[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#sorted] => 1
)

[preview] => Array
(
[#type] => button
[#value] => Preview
[#weight] => 40
[#set_name] => op
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => preview
)

[#processed] =>
[#description] =>
[#attributes] => Array
(
[style] => height:0px; visibility:hidden;
)

[#required] =>
[#input] => 1
[#name] => op
[#button_type] => submit
[#executes_submit_callback] =>
[#id] => edit-preview
[#sorted] => 1
)

[submit] => Array
(
[#type] => submit
[#value] => Submit
[#weight] => 45
[#set_name] => op
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => submit
)

[#processed] =>
[#description] =>
[#attributes] => Array
(
[style] => height:0px; visibility:hidden;
)

[#required] =>
[#input] => 1
[#name] => op
[#button_type] => submit
[#executes_submit_callback] => 1
[#id] => edit-submit
[#sorted] => 1
)

[#after_build] => Array
(
[0] => node_form_add_preview
)

[#base] => node_form
[#parameters] => Array
(
[0] => action_group_node_form
[1] => Array
(
[uid] => 3
[type] => action_group
)

)

[#process] => Array
(
[subform_element_separate_data_prepare] => Array
(
)

)

[#pre_render] => Array
(
[0] => subform_element_separate_data
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#type] => subform
[#programmed] => 1
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#tree] =>
[#parents] => Array
(
)

[#method] => post
[#action] => /eng/node/add/action
[#validate] => Array
(
[node_form_validate] => Array
(
)

)

[#submit] => Array
(
[node_form_submit] => Array
(
)

)

[comment_settings] => Array
(
[#type] => fieldset
[#access] =>
[#title] => Comment settings
[#collapsible] => 1
[#collapsed] => 1
[#weight] => 30
[comment] => Array
(
[#type] => radios
[#parents] => Array
(
[0] => comment
)

[#default_value] => 0
[#options] => Array
(
[0] => Disabled
[1] => Read only
[2] => Read/Write
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#weight] => 0
[#processed] => 1
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#process] => Array
(
[expand_radios] => Array
(
)

)

[#name] => comment
[#id] => edit-comment
[#value] => 0
[0] => Array
(
[#type] => radio
[#title] => Disabled
[#return_value] => 0
[#default_value] => 0
[#attributes] => Array
(
)

[#parents] => Array
(
[0] => comment
)

[#spawned] => 1
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#weight] => 0
[#processed] =>
[#description] =>
[#required] =>
[#input] => 1
[#name] => comment
[#id] => edit-comment
[#value] => 0
[#sorted] => 1
)

[1] => Array
(
[#type] => radio
[#title] => Read only
[#return_value] => 1
[#default_value] => 0
[#attributes] => Array
(
)

[#parents] => Array
(
[0] => comment
)

[#spawned] => 1
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#weight] => 0.001
[#processed] =>
[#description] =>
[#required] =>
[#input] => 1
[#name] => comment
[#id] => edit-comment
[#value] => 0
[#sorted] => 1
)

[2] => Array
(
[#type] => radio
[#title] => Read/Write
[#return_value] => 2
[#default_value] => 0
[#attributes] => Array
(
)

[#parents] => Array
(
[0] => comment
)

[#spawned] => 1
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#weight] => 0.002
[#processed] =>
[#description] =>
[#required] =>
[#input] => 1
[#name] => comment
[#id] => edit-comment
[#value] => 0
[#sorted] => 1
)

[#sorted] => 1
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => comment_settings
)

[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#sorted] => 1
)

[og_public] => Array
(
[#type] => value
[#value] => 1
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => og_public
)

[#weight] => 0.014
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => og_public
[#id] => edit-og-public
[#sorted] => 1
)

[og_description] => Array
(
[#type] => textfield
[#title] => Description
[#default_value] =>
[#size] => 70
[#maxlength] => 150
[#required] => 1
[#description] => A brief description for the group details block and the group directory.
[#weight] => -4
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => og_description
)

[#processed] =>
[#attributes] => Array
(
)

[#input] => 1
[#autocomplete_path] =>
[#name] => og_description
[#id] => edit-og-description
[#value] => Short description of joined form action group.
[#needs_validation] => 1
[#sorted] => 1
)

[og_selective] => Array
(
[#type] => value
[#value] => 0
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => og_selective
)

[#weight] => 0.016
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => og_selective
[#id] => edit-og-selective
[#sorted] => 1
)

[og_register] => Array
(
[#type] => value
[#value] => 0
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => og_register
)

[#weight] => 0.017
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => og_register
[#id] => edit-og-register
[#sorted] => 1
)

[og_directory] => Array
(
[#type] => value
[#value] => 1
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => og_directory
)

[#weight] => 0.018
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => og_directory
[#id] => edit-og-directory
[#sorted] => 1
)

[body_filter] => Array
(
[body] => Array
(
[#title] => Mission statement
[#description] => A welcome greeting for your group home page. Consider listing the group objectives and mission.
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => body
)

[#weight] => 0
[#processed] =>
[#sorted] => 1
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => body_filter
)

[#weight] => 0.019
[#processed] =>
[#sorted] => 1
)

[subscriptions] => Array
(
[subscriptions_currentstatus] => Array
(
[#type] => value
[#value] => 1
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => subscriptions_currentstatus
)

[#weight] => 0
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => subscriptions_currentstatus
[#id] => edit-subscriptions-currentstatus
[#sorted] => 1
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => subscriptions
)

[#weight] => 0.02
[#processed] =>
[#sorted] => 1
)

[menu] => Array
(
[#type] => fieldset
[#title] => Menu settings
[#access] =>
[#collapsible] => 1
[#collapsed] => 1
[#tree] => 1
[#weight] => 30
[title] => Array
(
[#type] => textfield
[#title] => Title
[#default_value] =>
[#description] => The name to display for this menu link.
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] => 1
[#access] =>
[#parents] => Array
(
[0] => menu
[1] => title
)

[#weight] => 0
[#processed] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#size] => 60
[#maxlength] => 128
[#autocomplete_path] =>
[#name] => menu[title]
[#id] => edit-menu-title
[#value] =>
[#sorted] => 1
)

[description] => Array
(
[#type] => textfield
[#title] => Description
[#default_value] =>
[#description] => The description displayed when hovering over a menu item.
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] => 1
[#access] =>
[#parents] => Array
(
[0] => menu
[1] => description
)

[#weight] => 0.001
[#processed] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#size] => 60
[#maxlength] => 128
[#autocomplete_path] =>
[#name] => menu[description]
[#id] => edit-menu-description
[#value] =>
[#sorted] => 1
)

[pid] => Array
(
[#type] => select
[#title] => Parent item
[#default_value] =>
[#options] => Array
(
[1] => Navigation
[103] => -- Groups
[3] => -- Compose tips (disabled)
[4] => -- Content (disabled)
[9] => ---- Create content (disabled)
[100] => ------ Action
[95] => ------ Action group
[79] => ------ FAQ
[67] => ------ Image
[21] => ------ Page
[96] => ------ Profile
[22] => ------ Story
[60] => ------ Usernode
[98] => -- Database queries
[89] => -- Directory (disabled)
[107] => -- Image galleries (disabled)
[55] => -- My subscriptions
[104] => -- My unread
[57] => -- My usernode (disabled)
[85] => -- Node locations
[76] => -- Profile wizard
[61] => -- Recent posts
[69] => -- Search (disabled)
[112] => -- Tags (disabled)
[84] => -- User locations
[80] => -- FAQ
[49] => -- Invite
[5] => -- Administer
[8] => ---- Content management
[36] => ------ Categories
[15] => ------ Comments
[18] => ------ Content
[20] => ------ Content types
[82] => ------ Flagged items
[108] => ------ Image galleries
[45] => ------ Node family
[19] => ------ Post settings
[31] => ------ RSS publishing
[66] => ------ Search content
[47] => ------ Translations
[11] => ---- Site building
[14] => ------ Blocks
[105] => ------ Contact form
[17] => ------ Menus
[25] => ------ Modules
[88] => ------ Panels
[24] => ------ Themes
[68] => ------ URL aliases
[58] => ------ Views
[102] => ------ Workflow-ng
[52] => ---- Organic groups
[62] => ------ Organic groups configuration
[10] => ---- Site configuration
[23] => ------ Administration theme
[75] => ------ Captcha
[97] => ------ Checkall boxes
[34] => ------ Clean URLs
[32] => ------ Date and time
[99] => ------ Devel
[27] => ------ Error reporting
[29] => ------ File system
[72] => ------ File uploads
[46] => ------ Fivestar
[81] => ------ Flag content
[74] => ------ Form store
[78] => ------ Frequently Asked Questions Settings
[77] => ------ Generate installation profile
[83] => ------ GMap
[86] => ------ GMap Location
[65] => ------ Image
[110] => ------ Image cache
[109] => ------ Image gallery
[30] => ------ Image toolkit
[16] => ------ Input formats
[64] => ------ Localization
[87] => ------ Location
[63] => ------ Multilingual system
[28] => ------ Performance
[118] => ------ Place
[70] => ------ Search settings
[26] => ------ Site information
[33] => ------ Site maintenance
[54] => ------ Subscriptions
[111] => ------ Tagadelic configuration
[101] => ------ Throttle
[59] => ------ Voting API
[53] => ---- Registration role
[13] => ---- User management
[39] => ------ Access control
[41] => ------ Access rules
[48] => ------ Invite settings
[50] => ------ LoginToboggan
[40] => ------ Roles
[73] => ------ Search users
[37] => ------ Users
[38] => ------ User settings
[12] => ---- Logs
[42] => ------ Recent log entries
[44] => ------ Top 'access denied' errors
[43] => ------ Top 'page not found' errors
[71] => ------ Top search phrases
[56] => ------ Available updates
[35] => ------ Status report
[7] => ---- Help
[6] => -- Log out
[2] => Primary links
[90] => -- Home
[93] => -- About the WSF
[94] => -- Media Center
[92] => -- Help Desk
[117] => -- Promote the Call
[91] => -- Login
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] => 1
[#access] =>
[#parents] => Array
(
[0] => menu
[1] => pid
)

[#weight] => 0.002
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => menu[pid]
[#id] => edit-menu-pid
[#value] =>
[#sorted] => 1
)

[path] => Array
(
[#type] => hidden
[#value] =>
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] => 1
[#access] =>
[#parents] => Array
(
[0] => menu
[1] => path
)

[#weight] => 0.003
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => menu[path]
[#id] => edit-menu-path
[#sorted] => 1
)

[weight] => Array
(
[#type] => select
[#title] => Weight
[#default_value] =>
[#delta] => 10
[#description] => Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] => 1
[#access] =>
[#parents] => Array
(
[0] => menu
[1] => weight
)

[#weight] => 0.004
[#processed] => 1
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#process] => Array
(
[process_weight] => Array
(
)

)

[#name] => menu[weight]
[#id] => edit-menu-weight
[#value] => 0
[#options] => Array
(
[-10] => -10
[-9] => -9
[-8] => -8
[-7] => -7
[-6] => -6
[-5] => -5
[-4] => -4
[-3] => -3
[-2] => -2
[-1] => -1
[0] => 0
[1] => 1
[2] => 2
[3] => 3
[4] => 4
[5] => 5
[6] => 6
[7] => 7
[8] => 8
[9] => 9
[10] => 10
)

[#is_weight] => 1
[#sorted] => 1
)

[mid] => Array
(
[#type] => hidden
[#value] => 0
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] => 1
[#access] =>
[#parents] => Array
(
[0] => menu
[1] => mid
)

[#weight] => 0.005
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => menu[mid]
[#id] => edit-menu-mid
[#sorted] => 1
)

[type] => Array
(
[#type] => hidden
[#value] => 86
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] => 1
[#access] =>
[#parents] => Array
(
[0] => menu
[1] => type
)

[#weight] => 0.006
[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#name] => menu[type]
[#id] => edit-menu-type
[#sorted] => 1
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#parents] => Array
(
[0] => menu
)

[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#sorted] => 1
)

[path] => Array
(
[#type] => fieldset
[#title] => URL path settings
[#collapsible] => 1
[#collapsed] => 1
[#access] =>
[#weight] => 30
[path] => Array
(
[#type] => textfield
[#default_value] =>
[#maxlength] => 250
[#collapsible] => 1
[#collapsed] => 1
[#description] => Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don't add a trailing slash or the URL alias won't work.
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#access] =>
[#parents] => Array
(
[0] => path
)

[#weight] => 0
[#processed] =>
[#attributes] => Array
(
)

[#required] =>
[#input] => 1
[#size] => 60
[#autocomplete_path] =>
[#name] => path
[#id] => edit-path
[#value] =>
[#sorted] => 1
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] =>
[#parents] => Array
(
[0] => path
)

[#processed] =>
[#description] =>
[#attributes] => Array
(
)

[#required] =>
[#sorted] => 1
)

[taxonomy] => Array
(
[tags] => Array
(
[1] => Array
(
[#type] => textfield
[#title] => Organization
[#description] => Name the organization or organizations with which you affiliate. If you think someone may have entered your organization already, type a few letters and wait for autocomplete to get an exact match.
[#required] => 0
[#default_value] =>
[#autocomplete_path] => taxonomy/autocomplete/1
[#weight] => -6
[#maxlength] => 255
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] => 1
[#parents] => Array
(
[0] => taxonomy
[1] => tags
[2] => 1
)

[#processed] =>
[#attributes] => Array
(
)

[#input] => 1
[#size] => 60
[#name] => taxonomy[tags][1]
[#id] => edit-taxonomy-tags-1
[#value] => Joined Form Action Group Organization
[#needs_validation] => 1
[#sorted] => 1
)

[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#tree] => 1
[#parents] => Array
(
[0] => taxonomy
[1] => tags
)

[#weight] => 0
[#processed] =>
)

[#weight] => -3
[#tree] => 1
[#post] => Array
(
[title] => Joined form action group
[og_description] => Short description of joined form action group.
[taxonomy] => Array
(
[tags] => Array
(
[1] => Joined Form Action Group Organization
)

)

[changed] =>
[log] =>
[form_id] => action_group_node_form
)

[#programmed] => 1
[#parents] => Array
(
[0] => taxonomy
)

[#processed] =>
[#sorted] => 1
)

[#processed] => 1
[#after_build_done] => 1
[#validated] =>
)

)

Resolution

Searched words: 
inline nodereference drupal nodereference one form one-step nodereference node creation nodereference form inside form embed form in form drupal nodereference node while creating node nodereference create node while submitting node create nodereference node while submitting node module

Comments

Notes that led nowhere,

Notes that led nowhere, since this page is already out of control:

If documentation to something reasonable emerges, it will be linked to from the TOP of this page.

drupal submit node return nid

So what Agaric is doing here is combining two forms. So this is NOT really the programmatic submission of forms, but intercepting the normal submission.

drupal combine two forms into one
Subform Element module:
https://more.zites.net/taxonomy/term/43
http://drupal.org/project/subform_element
Docs: http://drupal.org/node/133725

old, nothing definitive:

How to programmatically create nodereferences
http://drupal.org/node/148022

Create Node Programmatically
http://drupal.org/node/154570

Best documentation
http://www.lullabot.com/articles/quick_and_dirty_cck_imports

Linked from http://www.civicactions.com/blog/cck_import_and_update
where the strong recommendation is made to insert and update nodes is with drupal_execute, rather than node_submit because it handles form alter and form validation.

drupal get nid last saved node
get nid of new saved node

Drupal override form submit handling

Joining forms: figuring out what's in the form.
If your
print “

“; print_r(array_values($form));print “

“;
statement isn't giving anything useful, there must be a module modifying the form after yours– a module with a higher weight form_altering after yours.

Change your weight. See: http://agaricdesign.com/note/set-weight-drupal-module

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.