public function DynamicFormSections::promptCallback in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/ajax_example/src/Form/DynamicFormSections.php \Drupal\ajax_example\Form\DynamicFormSections::promptCallback()
Callback for the select element.
Since the questions_fieldset part of the form has already been built during the AJAX request, we can return only that part of the form to the AJAX request, and it will insert that part into questions-fieldset-wrapper.
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 form structure.
File
- ajax_example/
src/ Form/ DynamicFormSections.php, line 219
Class
- DynamicFormSections
- Dynamically-enabled form with graceful no-JS degradation.
Namespace
Drupal\ajax_example\FormCode
public function promptCallback(array $form, FormStateInterface $form_state) {
return $form['questions_fieldset'];
}