public function FormValidationMessageOrderTest::buildForm in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Form/FormValidationMessageOrderTest.php \Drupal\KernelTests\Core\Form\FormValidationMessageOrderTest::buildForm()
Form constructor.
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 form structure.
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;
}