You are here

function webform_components_form_submit in Webform 7.4

Same name and namespace in other branches
  1. 5.2 webform_components.inc \webform_components_form_submit()
  2. 6.3 includes/webform.components.inc \webform_components_form_submit()
  3. 6.2 webform_components.inc \webform_components_form_submit()
  4. 7.3 includes/webform.components.inc \webform_components_form_submit()

Submit handler for webform_components_form() to save component order.

File

includes/webform.components.inc, line 341
Webform module component handling.

Code

function webform_components_form_submit($form, &$form_state) {
  $node = node_load($form_state['values']['nid']);

  // Update all required and weight values.
  $changes = FALSE;
  foreach ($node->webform['components'] as $cid => $component) {
    if ($component['pid'] != $form_state['values']['components'][$cid]['pid'] || $component['weight'] != $form_state['values']['components'][$cid]['weight'] || $component['required'] != $form_state['values']['components'][$cid]['required']) {
      $changes = TRUE;
      $node->webform['components'][$cid]['weight'] = $form_state['values']['components'][$cid]['weight'];
      $node->webform['components'][$cid]['required'] = $form_state['values']['components'][$cid]['required'];
      $node->webform['components'][$cid]['pid'] = $form_state['values']['components'][$cid]['pid'];
    }
  }
  if ($changes) {
    node_save($node);
  }
  drupal_set_message(t('The component positions and required values have been updated.'));
}