diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index 480f9b8..bd55bc4 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -1209,4 +1209,3 @@ function ajax_command_add_css($styles) { 'data' => $styles, ); } - diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/CommandsTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/CommandsTest.php index 5b137d3..faa35bb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/CommandsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/CommandsTest.php @@ -162,7 +162,7 @@ class CommandsTest extends AjaxTestBase { $commands = $this->drupalPostAJAX($form_path, $edit, array('op' => t("AJAX 'add_css' command"))); $expected = array( 'command' => 'add_css', - 'data' => array('my/file.css'), + 'data' => 'my/file.css', ); $this->assertCommand($commands, $expected, "'add_css' AJAX command issued with correct data"); } diff --git a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module index 6a95710..d4074d1 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module +++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module @@ -258,6 +258,15 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) { ), ); + // Shows the Ajax 'add_css' command. + $form['add_css_command_example'] = array( + '#type' => 'submit', + '#value' => t("AJAX 'add_css' command"), + '#ajax' => array( + 'callback' => 'ajax_forms_test_advanced_commands_add_css_callback', + ), + ); + $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), @@ -411,6 +420,15 @@ function ajax_forms_test_advanced_commands_settings_callback($form, $form_state) } /** + * Ajax callback for 'add_css'. + */ +function ajax_forms_test_advanced_commands_add_css_callback($form, $form_state) { + $commands = array(); + $commands[] = ajax_command_add_css('my/file.css'); + return array('#type' => 'ajax', '#commands' => $commands); +} + +/** * This form and its related submit and callback functions demonstrate * not validating another form element when a single Ajax element is triggered. *