public function AjaxTestFormPromise::buildForm in Drupal 10
Form for testing the addition of various types of elements via Ajax.
Overrides FormInterface::buildForm
File
- core/
modules/ system/ tests/ modules/ ajax_test/ src/ Form/ AjaxTestFormPromise.php, line 28
Class
- AjaxTestFormPromise
- Test form for ajax_test_form_promise.
Namespace
Drupal\ajax_test\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#attached']['library'][] = 'ajax_test/command_promise';
$form['custom']['#prefix'] = '<div id="ajax_test_form_promise_wrapper">';
$form['custom']['#suffix'] = '</div>';
// Button to test for the execution order of Ajax commands.
$form['test_execution_order_button'] = [
'#type' => 'submit',
'#value' => $this
->t('Execute commands button'),
'#button_type' => 'primary',
'#ajax' => [
'callback' => [
static::class,
'executeCommands',
],
'progress' => [
'type' => 'throbber',
'message' => NULL,
],
'wrapper' => 'ajax_test_form_promise_wrapper',
],
];
return $form;
}