public function AjaxFormBlock::updateOptions in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php \Drupal\ajax_forms_test\Plugin\Block\AjaxFormBlock::updateOptions()
- 10 core/modules/system/tests/modules/ajax_forms_test/src/Plugin/Block/AjaxFormBlock.php \Drupal\ajax_forms_test\Plugin\Block\AjaxFormBlock::updateOptions()
Updates the options of a select list.
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 updated form element.
File
- core/
modules/ system/ tests/ modules/ ajax_forms_test/ src/ Plugin/ Block/ AjaxFormBlock.php, line 125
Class
- AjaxFormBlock
- Provides an AJAX form block.
Namespace
Drupal\ajax_forms_test\Plugin\BlockCode
public function updateOptions(array $form, FormStateInterface $form_state) {
$form['test1']['#options']['option1'] = $this
->t('Option 1!!!');
$form['test1']['#options'] += [
'option3' => $this
->t('Option 3'),
'option4' => $this
->t('Option 4'),
];
return $form['test1'];
}