You are here

function webform_form_alter in Webform 6.3

Same name and namespace in other branches
  1. 8.5 includes/webform.form_alter.inc \webform_form_alter()
  2. 5.2 webform.module \webform_form_alter()
  3. 6.2 webform.module \webform_form_alter()
  4. 7.4 webform.module \webform_form_alter()
  5. 7.3 webform.module \webform_form_alter()
  6. 6.x includes/webform.form_alter.inc \webform_form_alter()

Implements hook_form_alter().

File

./webform.module, line 1279

Code

function webform_form_alter(&$form, $form_state, $form_id) {
  $matches = array();
  if (isset($form['#node']->type) && $form_id == $form['#node']->type . '_node_form' && in_array($form['#node']->type, webform_variable_get('webform_node_types'))) {
    $node = $form['#node'];

    // Preserve all Webform options currently set on the node.
    $form['webform'] = array(
      '#type' => 'value',
      '#value' => $node->webform,
    );

    // If a new node, redirect the user to the components form after save.
    if (empty($node->nid) && in_array($node->type, webform_variable_get('webform_node_types_primary'))) {
      $form['buttons']['submit']['#submit'][] = 'webform_form_submit';
    }
  }
}