Currently our webform_config_form_submit() function is impossible to extend in any way. At the beginning of the function we node_load() a NID, then node_save() at the bottom of it. While this is great use of API functions, it's impossible to extend this submit handler to save any additional properties (such as if you wanted to make the node title changeable from this form, or add additional properties into the $node->webform array).

This patch does 3 related things:
- Instead of node_load() at the beginning of the submit function, the $node that is passed into the form builder function is just kept in $form['#node']. This matches other places where the node is usually edited or used, such as the node form or even on a Webform client form.
- The call to node_save() is moved into a separate submit handler, so modules can insert an additional submit handler before it is called.
- The submit button is changed to use a #type='actions' wrapper to match Drupal 7 conventions. (Maybe not super-related but has to do with the submit all the same).

CommentFileSizeAuthor
webform_config_form_submit.patch1.97 KBquicksketch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Status: Needs review » Fixed

Checked one more time and committed to both branches of the project.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

alexverb’s picture

Category: task » support
Status: Closed (fixed) » Fixed

Is it possible for anyone to enlighten me how I can add additional properties through my own submit function? I've tried something in the lines of:

function webform_extra_form_webform_configure_form_alter(&$form, $form_state) {

  $form['advanced']['extra'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable extra'),
    '#default_value' => isset($form['#node']->webform['extra']) ? $form['#node']->webform['extra'] : 0,
  );
  // Add our submit handler
  array_unshift($form['#submit'], 'webform_extra_form_webform_configure_form_submit');
}

function webform_extra_form_webform_configure_form_submit(&$form, &$form_state) {
  // Not working for some reason
  $form['#node']->webform['extra'] = $form_state['values']['extra'];
}

But I can't seem to retain the additional value through the new node_save() submit handler. What am I overlooking here?

quicksketch’s picture

See this handbook page: http://drupal.org/node/1291574

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.