1 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 backdrop_set_message().

File

modules/examples/form_example/form_example_tutorial.inc, line 480
This is the form API tutorial.

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 backdrop_set_message()
  // to validate that the code worked.
  $page_one_values = $form_state['page_values'][1];
  backdrop_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'])) {
    backdrop_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'],
    )
    ));
  }
  backdrop_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']. For
  // simple redirects, the value can be a string of the path to redirect to.
  // For example, to redirect to /node, one would use the following code:
  //
  // @code
  // $form_state['redirect'] = 'node';
  // @endcode
  //
  // For more complex redirects, this value can be set to an array of options to
  // pass to backdrop_goto(). For example, to redirect to /foo?bar=1#baz, one
  // would specify the following:
  //
  // @code
  // $form_state['redirect'] = array(
  //   'foo',
  //   array(
  //     'query' => array('bar' => 1),
  //     'fragment' => 'baz',
  //   ),
  // );
  // @endcode
  //
  // The first element in the array is the path to redirect to, and the second
  // element in the array is the array of options. For more information on the
  // available options, see url().
}