class JSInteractionTestForm
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/js_interaction_test/src/Controller/JSInteractionTestForm.php \Drupal\js_interaction_test\Controller\JSInteractionTestForm
- 10 core/modules/system/tests/modules/js_interaction_test/src/Controller/JSInteractionTestForm.php \Drupal\js_interaction_test\Controller\JSInteractionTestForm
Controller for testing fault tolerant JavaScript interactions.
Hierarchy
- class \Drupal\Core\Form\FormBase implements \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\js_interaction_test\Controller\JSInteractionTestForm extends \Drupal\Core\Form\FormBase
Expanded class hierarchy of JSInteractionTestForm
1 string reference to 'JSInteractionTestForm'
- js_interaction_test.routing.yml in core/
modules/ system/ tests/ modules/ js_interaction_test/ js_interaction_test.routing.yml - core/modules/system/tests/modules/js_interaction_test/js_interaction_test.routing.yml
File
-
core/
modules/ system/ tests/ modules/ js_interaction_test/ src/ Controller/ JSInteractionTestForm.php, line 12
Namespace
Drupal\js_interaction_test\ControllerView source
class JSInteractionTestForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return __CLASS__;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// No-op.
}
/**
* 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.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return array
* The form structure.
*/
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.