function Callbacks::checkboxCallback
Same name in other branches
- 9 core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php \Drupal\ajax_forms_test\Callbacks::checkboxCallback()
- 8.9.x core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php \Drupal\ajax_forms_test\Callbacks::checkboxCallback()
- 10 core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php \Drupal\ajax_forms_test\Callbacks::checkboxCallback()
Ajax callback triggered by checkbox.
File
-
core/
modules/ system/ tests/ modules/ ajax_forms_test/ src/ Callbacks.php, line 53
Class
- Callbacks
- Simple object for testing methods as Ajax callbacks.
Namespace
Drupal\ajax_forms_testCode
public function checkboxCallback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new HtmlCommand('#ajax_checkbox_value', $form_state->getValue('checkbox') ? 'checked' : 'unchecked'));
$response->addCommand(new DataCommand('#ajax_checkbox_value', 'form_state_value_select', (int) $form_state->getValue('checkbox')));
return $response;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.