function AjaxFormBlock::buildForm
Same name in other branches
- 9 core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php \Drupal\ajax_forms_test\Plugin\Block\AjaxFormBlock::buildForm()
- 8.9.x core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php \Drupal\ajax_forms_test\Plugin\Block\AjaxFormBlock::buildForm()
- 10 core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php \Drupal\ajax_forms_test\Plugin\Block\AjaxFormBlock::buildForm()
Overrides FormInterface::buildForm
File
-
core/
modules/ system/ tests/ modules/ ajax_forms_test/ src/ Plugin/ Block/ AjaxFormBlock.php, line 91
Class
- AjaxFormBlock
- Provides an AJAX form block.
Namespace
Drupal\ajax_forms_test\Plugin\BlockCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['test1'] = [
'#type' => 'select',
'#title' => $this->t('Test 1'),
'#required' => TRUE,
'#options' => [
'option1' => $this->t('Option 1'),
'option2' => $this->t('Option 2'),
],
'#ajax' => [
'callback' => '::updateOptions',
'wrapper' => 'edit-test1-wrapper',
],
'#prefix' => '<div id="edit-test1-wrapper">',
'#suffix' => '</div>',
];
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.