class JsAjaxTestForm
Same name and namespace in other branches
- 8.9.x core/modules/system/tests/modules/js_ajax_test/src/Form/JsAjaxTestForm.php \Drupal\js_ajax_test\Form\JsAjaxTestForm
Test form for js_ajax_test.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase extends \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_ajax_test\Form\JsAjaxTestForm implements \Drupal\Core\Form\FormBase
Expanded class hierarchy of JsAjaxTestForm
1 string reference to 'JsAjaxTestForm'
- js_ajax_test.routing.yml in core/
modules/ system/ tests/ modules/ js_ajax_test/ js_ajax_test.routing.yml - core/modules/system/tests/modules/js_ajax_test/js_ajax_test.routing.yml
File
-
core/
modules/ system/ tests/ modules/ js_ajax_test/ src/ Form/ JsAjaxTestForm.php, line 15
Namespace
Drupal\js_ajax_test\FormView source
class JsAjaxTestForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'js_ajax_test_form';
}
/**
* Form for testing the addition of various types of elements via Ajax.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#attached']['library'][] = 'js_ajax_test/ajax';
$form['custom']['#prefix'] = '<div id="js_ajax_test_form_wrapper">';
$form['custom']['#suffix'] = '</div>';
// Button to test for the waitForButton() assertion.
$form['test_button'] = [
'#type' => 'submit',
'#value' => $this->t('Add button'),
'#button_type' => 'primary',
'#ajax' => [
'callback' => [
static::class,
'addButton',
],
'progress' => [
'type' => 'throbber',
'message' => NULL,
],
'wrapper' => 'js_ajax_test_form_wrapper',
],
];
return $form;
}
/**
* Ajax callback for the "Add button" button.
*/
public static function addButton(array $form, FormStateInterface $form_state) {
return (new AjaxResponse())->addCommand(new JsAjaxTestCommand());
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// An empty implementation, as we never submit the actual form.
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.