function Callbacks::advancedCommandsCssCallback

Ajax form callback: Selects 'css'.

File

core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php, line 180

Class

Callbacks
Simple object for testing methods as Ajax callbacks.

Namespace

Drupal\ajax_forms_test

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.