function PathElementFormTest::buildForm
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php \Drupal\KernelTests\Core\Element\PathElementFormTest::buildForm()
- 10 core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php \Drupal\KernelTests\Core\Element\PathElementFormTest::buildForm()
- 11.x core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php \Drupal\KernelTests\Core\Element\PathElementFormTest::buildForm()
Overrides FormInterface::buildForm
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Element/ PathElementFormTest.php, line 68
Class
- PathElementFormTest
- Tests PathElement validation and conversion functionality.
Namespace
Drupal\KernelTests\Core\ElementCode
public function buildForm(array $form, FormStateInterface $form_state) {
// A required validated path.
$form['required_validate'] = [
'#type' => 'path',
'#required' => TRUE,
'#title' => 'required_validate',
'#convert_path' => PathElement::CONVERT_NONE,
];
// A non validated required path.
$form['required_non_validate'] = [
'#type' => 'path',
'#required' => TRUE,
'#title' => 'required_non_validate',
'#convert_path' => PathElement::CONVERT_NONE,
'#validate_path' => FALSE,
];
// A non required validated path.
$form['optional_validate'] = [
'#type' => 'path',
'#required' => FALSE,
'#title' => 'optional_validate',
'#convert_path' => PathElement::CONVERT_NONE,
];
// A non required converted path.
$form['optional_validate'] = [
'#type' => 'path',
'#required' => FALSE,
'#title' => 'optional_validate',
'#convert_path' => PathElement::CONVERT_ROUTE,
];
// A converted required validated path.
$form['required_validate_route'] = [
'#type' => 'path',
'#required' => TRUE,
'#title' => 'required_validate_route',
];
// A converted required validated path.
$form['required_validate_url'] = [
'#type' => 'path',
'#required' => TRUE,
'#title' => 'required_validate_url',
'#convert_path' => PathElement::CONVERT_URL,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.