You are here

function _rest_server_settings_checkboxes_attributes in Services 7.3

Same name and namespace in other branches
  1. 6.3 servers/rest_server/rest_server.inc \_rest_server_settings_checkboxes_attributes()

Utility function that creates attributes for a checkboxes-type form element from a rest server settings array.

Parameters

array $settings:

Return value

array

1 call to _rest_server_settings_checkboxes_attributes()
_rest_server_settings in servers/rest_server/rest_server.inc
REST server settings form. Generates the form fragment for configuring the REST server for an endpoint.

File

servers/rest_server/rest_server.inc, line 45
Autoload classes and server settings.

Code

function _rest_server_settings_checkboxes_attributes($settings) {
  $keys = array_keys($settings);
  $options = array_combine($keys, $keys);
  $default = array();
  foreach ($settings as $key => $enabled) {
    if ($enabled) {
      $default[] = $key;
    }
  }
  ksort($options);
  return array(
    '#options' => $options,
    '#default_value' => $default,
  );
}