function MultistepForm::fapiExamplePageTwo
Same name in other branches
- 8.x-1.x form_api_example/src/Form/MultistepForm.php \Drupal\form_api_example\Form\MultistepForm::fapiExamplePageTwo()
- 4.0.x modules/form_api_example/src/Form/MultistepForm.php \Drupal\form_api_example\Form\MultistepForm::fapiExamplePageTwo()
Builds the second step form (page 2).
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The render array defining the elements of the form.
1 call to MultistepForm::fapiExamplePageTwo()
- MultistepForm::buildForm in modules/
form_api_example/ src/ Form/ MultistepForm.php - Form constructor.
File
-
modules/
form_api_example/ src/ Form/ MultistepForm.php, line 149
Class
- MultistepForm
- Provides a form with two steps.
Namespace
Drupal\form_api_example\FormCode
public function fapiExamplePageTwo(array &$form, FormStateInterface $form_state) {
$form['description'] = [
'#type' => 'item',
'#title' => $this->t('A basic multistep form (page 2)'),
];
$form['color'] = [
'#type' => 'textfield',
'#title' => $this->t('Favorite color'),
'#required' => TRUE,
'#default_value' => $form_state->getValue('color', ''),
];
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['back'] = [
'#type' => 'submit',
'#value' => $this->t('Back'),
// Custom submission handler for 'Back' button.
'#submit' => [
'::fapiExamplePageTwoBack',
],
// We won't bother validating the required 'color' field, since they
// have to come back to this page to submit anyway.
'#limit_validation_errors' => [],
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => $this->t('Submit'),
];
return $form;
}