You are here

function webform_components_form_submit in Webform 6.3

Same name and namespace in other branches
  1. 5.2 webform_components.inc \webform_components_form_submit()
  2. 6.2 webform_components.inc \webform_components_form_submit()
  3. 7.4 includes/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 311
Webform module component handling.

Code

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

  // Update all mandatory 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['mandatory'] != $form_state['values']['components'][$cid]['mandatory']) {
      $changes = TRUE;
      $node->webform['components'][$cid]['weight'] = $form_state['values']['components'][$cid]['weight'];
      $node->webform['components'][$cid]['mandatory'] = $form_state['values']['components'][$cid]['mandatory'];
      $node->webform['components'][$cid]['pid'] = $form_state['values']['components'][$cid]['pid'];
    }
  }
  if ($changes) {
    node_save($node);
  }
  drupal_set_message(t('The component positions and mandatory values have been updated.'));
}