function JSInteractionTestForm::buildForm
Same name in other branches
- 9 core/modules/system/tests/modules/js_interaction_test/src/Controller/JSInteractionTestForm.php \Drupal\js_interaction_test\Controller\JSInteractionTestForm::buildForm()
- 10 core/modules/system/tests/modules/js_interaction_test/src/Controller/JSInteractionTestForm.php \Drupal\js_interaction_test\Controller\JSInteractionTestForm::buildForm()
Creates the test form.
The form provides:
- A link that is obstructed (blocked) by another element.
- A link that, when clicked, removes the blocking element after some time.
- A field that is disabled.
- A link that, when clicked, enables the field after some time.
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/
modules/ system/ tests/ modules/ js_interaction_test/ src/ Controller/ JSInteractionTestForm.php, line 47
Class
- JSInteractionTestForm
- Controller for testing fault tolerant JavaScript interactions.
Namespace
Drupal\js_interaction_test\ControllerCode
public function buildForm(array $form, FormStateInterface $form_state) {
return [
'target_link' => [
'#type' => 'link',
'#url' => Url::fromRoute('<current>'),
'#title' => $this->t('Target link'),
],
'blocker_element' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'class' => [
'blocker-element',
],
],
],
'remove_blocker_trigger' => [
'#type' => 'link',
'#url' => Url::fromRoute('<current>'),
'#title' => $this->t('Remove Blocker Trigger'),
'#attributes' => [
'class' => [
'remove-blocker-trigger',
],
],
],
'target_field' => [
'#type' => 'textfield',
'#maxlength' => 20,
'#disabled' => TRUE,
],
'enable_field_trigger' => [
'#type' => 'link',
'#url' => Url::fromRoute('<current>'),
'#title' => $this->t('Enable Field Trigger'),
'#attributes' => [
'class' => [
'enable-field-trigger',
],
],
],
'#attached' => [
'library' => [
'js_interaction_test/js_interaction_test',
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.