You are here

class Callbacks in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php \Drupal\ajax_forms_test\Callbacks
  2. 8 core/modules/system/tests/modules/form_test/src/Callbacks.php \Drupal\form_test\Callbacks
Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php \Drupal\ajax_forms_test\Callbacks

Simple object for testing methods as Ajax callbacks.

Hierarchy

Expanded class hierarchy of Callbacks

1 file declares its use of Callbacks
AjaxFormsTestSimpleForm.php in core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestSimpleForm.php
Contains \Drupal\ajax_forms_test\Form\AjaxFormsTestSimpleForm.

File

core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php, line 18
Contains \Drupal\ajax_forms_test\Callbacks.

Namespace

Drupal\ajax_forms_test
View source
class Callbacks {

  /**
   * Ajax callback triggered by select.
   */
  function selectCallback($form, FormStateInterface $form_state) {
    $response = new AjaxResponse();
    $response
      ->addCommand(new HtmlCommand('#ajax_selected_color', $form_state
      ->getValue('select')));
    $response
      ->addCommand(new DataCommand('#ajax_selected_color', 'form_state_value_select', $form_state
      ->getValue('select')));
    return $response;
  }

  /**
   * Ajax callback triggered by checkbox.
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Callbacks::checkboxCallback function Ajax callback triggered by checkbox.
Callbacks::selectCallback function Ajax callback triggered by select.