| 7 form_example_tutorial.inc | form_example_tutorial_8_page_two_submit($form, &$form_state) |
| 8 form_example_tutorial.inc | form_example_tutorial_8_page_two_submit($form, &$form_state) |
The page 2 submit handler.
This is the final submit handler. Gather all the data together and output it in a drupal_set_message().
1 string reference to 'form_example_tutorial_8_page_two_submit'
File
- form_example/
form_example_tutorial.inc, line 519 - This is the Form API Tutorial from the handbook.
Code
function form_example_tutorial_8_page_two_submit($form, &$form_state) {
// Normally, some code would go here to alter the database with the data
// collected from the form. Instead sets a message with drupal_set_message()
// to validate that the code worked.
$page_one_values = $form_state['page_values'][1];
drupal_set_message(t('The form has been submitted. name="@first @last", year of birth=@year_of_birth',
array('@first' => $page_one_values['first'], '@last' => $page_one_values['last'], '@year_of_birth' => $page_one_values['year_of_birth'])));
if (!empty($page_one_values['first2'])) {
drupal_set_message(t('Second name: name="@first @last", year of birth=@year_of_birth',
array('@first' => $page_one_values['first2'], '@last' => $page_one_values['last2'], '@year_of_birth' => $page_one_values['year_of_birth2'])));
}
drupal_set_message(t('And the favorite color is @color', array('@color' => $form_state['values']['color'])));
// If we wanted to redirect on submission, set $form_state['redirect']
// $form_state['redirect'] = 'node'; // Redirects the user to /node.
}
Login or register to post comments