function ajax_command_settings

Creates a Drupal Ajax 'settings' command.

The 'settings' command instructs the client either to use the given array as the settings for ajax-loaded content or to extend Drupal.settings with the given array, depending on the value of the $merge parameter.

This command is implemented by Drupal.ajax.prototype.commands.settings() defined in misc/ajax.js.


$argument: An array of key/value pairs to add to the settings. This will be utilized for all commands after this if they do not include their own settings array.

$merge: Whether or not the passed settings in $argument should be merged into the global Drupal.settings on the page. By default (FALSE), the settings that are passed to Drupal.attachBehaviors will not include the global Drupal.settings.

Return value

An array suitable for use with the ajax_render() function.

Related topics

2 calls to ajax_command_settings()
ajax_forms_test_advanced_commands_settings_callback in drupal/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.module
Ajax form callback: Selects 'settings'.
ajax_render in drupal/core/includes/
Renders a commands array into JSON.


drupal/core/includes/, line 1045
Functions for use with Drupal's Ajax framework.


function ajax_command_settings($argument, $merge = FALSE) {
  return array(
    'command' => 'settings',
    'settings' => $argument,
    'merge' => $merge,