1 form_example_tutorial.inc form_example_tutorial_9_add_name($form, &$form_state)

Submit handler for "Add another name" button on form_example_tutorial_9().

$form_state['num_names'] tells the form builder function how many name fieldsets to build, so here we increment it.

All elements of $form_state are persisted, so there's no need to use a particular key, like the old $form_state['storage']. We can just use $form_state['num_names'].


modules/examples/form_example/form_example_tutorial.inc, line 643
This is the Form API Tutorial, originally from the Backdrop handbook.


function form_example_tutorial_9_add_name($form, &$form_state) {
  // Everything in $form_state is persistent, so we'll just use
  // $form_state['add_name']

  // Setting $form_state['rebuild'] = TRUE causes the form to be rebuilt again.
  $form_state['rebuild'] = TRUE;