You are here

function Callbacks::checkboxCallback in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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 33
Contains \Drupal\ajax_forms_test\Callbacks.

Class

Callbacks
Simple object for testing methods as Ajax callbacks.

Namespace

Drupal\ajax_forms_test

Code

function checkboxCallback($form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $response
    ->addCommand(new HtmlCommand('#ajax_checkbox_value', (int) $form_state
    ->getValue('checkbox')));
  $response
    ->addCommand(new DataCommand('#ajax_checkbox_value', 'form_state_value_select', (int) $form_state
    ->getValue('checkbox')));
  return $response;
}