diff --git a/includes/webform.components.inc b/includes/webform.components.inc index 18e74bd..c6f3c1c 100644 --- a/includes/webform.components.inc +++ b/includes/webform.components.inc @@ -131,6 +131,7 @@ function webform_components_form($form, $form_state, $node) { '#type' => 'submit', '#value' => t('Add'), '#weight' => 45, + '#submit' => array('webform_components_form_add_submit'), ); $form['submit'] = array( @@ -140,6 +141,8 @@ function webform_components_form($form, $form_state, $node) { '#access' => count($node->webform['components']) > 0, ); + $form['#submit'] = array('webform_components_form_submit'); + return $form; } @@ -320,11 +323,7 @@ function webform_components_form_submit($form, &$form_state) { node_save($node); drupal_set_message(t('Your webform has been published.')); return 'node/' . $node->nid; - } - elseif (isset($_POST['op']) && $_POST['op'] == t('Add')) { - $component = $form_state['values']['add']; - $form_state['redirect'] = array('node/' . $node->nid . '/webform/components/new/' . $component['type'], array('query' => array('name' => $component['name'], 'mandatory' => $component['mandatory'], 'pid' => $component['pid'], 'weight' => $component['weight']))); - } + } else { drupal_set_message(t('The component positions and mandatory values have been updated.')); @@ -340,6 +339,16 @@ function webform_components_form_submit($form, &$form_state) { } } +function webform_components_form_add_submit($form, &$form_state) { + $node = node_load($form_state['values']['nid']); + + $component = $form_state['values']['add']; + $form_state['redirect'] = array('node/' . $node->nid . '/webform/components/new/' . $component['type'], array('query' => array('name' => $component['name'], 'mandatory' => $component['mandatory'], 'pid' => $component['pid'], 'weight' => $component['weight']))); +} + +/** + * Form to configure a webform component. + */ function webform_component_edit_form($form, $form_state, $node, $component, $clone = FALSE) { drupal_set_title(t('Edit component: @name', array('@name' => $component['name'])), PASS_THROUGH);