function FormValidationMessageOrderTest::buildForm
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Form/FormValidationMessageOrderTest.php \Drupal\KernelTests\Core\Form\FormValidationMessageOrderTest::buildForm()
- 10 core/tests/Drupal/KernelTests/Core/Form/FormValidationMessageOrderTest.php \Drupal\KernelTests\Core\Form\FormValidationMessageOrderTest::buildForm()
- 11.x core/tests/Drupal/KernelTests/Core/Form/FormValidationMessageOrderTest.php \Drupal\KernelTests\Core\Form\FormValidationMessageOrderTest::buildForm()
Overrides FormInterface::buildForm
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Form/ FormValidationMessageOrderTest.php, line 27
Class
- FormValidationMessageOrderTest
- Tests form validation messages are displayed in the same order as the fields.
Namespace
Drupal\KernelTests\Core\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Prepare fields with weights specified.
$form['one'] = [
'#type' => 'textfield',
'#title' => 'One',
'#required' => TRUE,
'#weight' => 40,
];
$form['two'] = [
'#type' => 'textfield',
'#title' => 'Two',
'#required' => TRUE,
'#weight' => 30,
];
$form['three'] = [
'#type' => 'textfield',
'#title' => 'Three',
'#required' => TRUE,
'#weight' => 10,
];
$form['four'] = [
'#type' => 'textfield',
'#title' => 'Four',
'#required' => TRUE,
'#weight' => 20,
];
$form['actions'] = [
'#type' => 'actions',
'submit' => [
'#type' => 'submit',
'#value' => 'Submit',
],
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.