Same name and namespace in other branches
  1. 7.x modules/simpletest/tests/ajax_forms_test.module \ajax_forms_test_advanced_commands_css_callback()
  2. 8.9.x core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module \ajax_forms_test_advanced_commands_css_callback()
  3. 9 core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module \ajax_forms_test_advanced_commands_css_callback()

Ajax form callback: Selects 'css'.

1 string reference to 'ajax_forms_test_advanced_commands_css_callback'
AjaxFormsTestCommandsForm::buildForm in core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestCommandsForm.php
.

File

core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module, line 117
Mock module for Ajax forms testing.

Code

function ajax_forms_test_advanced_commands_css_callback($form, FormStateInterface $form_state) {
  $selector = '#css_div';
  $color = 'blue';
  $response = new AjaxResponse();
  $response
    ->addCommand(new CssCommand($selector, [
    'background-color' => $color,
  ]));
  return $response;
}