You are here

function cshs_element_process in Client-side Hierarchical Select 7

1 string reference to 'cshs_element_process'
cshs_element_info in ./cshs.element.inc
Implements hook_element_info().

File

./cshs.element.inc, line 40

Code

function cshs_element_process($element, $form_state) {
  $path = drupal_get_path('module', 'cshs');

  // Add CSS and JS.
  $element += array(
    '#attached' => array(
      'css' => array(
        "{$path}/css/cshs.css",
      ),
      'js' => array(
        "{$path}/js/libs/jquery.simpler-select.js",
        "{$path}/js/cshs.js",
      ),
    ),
  );

  // Pass settings to JS.
  $id = $element['#id'];
  $settings_js = array(
    'cshs' => array(
      $id => array(
        'noneLabel' => $element['#none_label'],
        'noneValue' => $element['#none_value'],
        'labels' => $element['#labels'],
      ),
    ),
  );
  $element['#attached']['js'][] = array(
    'data' => $settings_js,
    'type' => 'setting',
  );
  return $element;
}