You are here

function vertical_tabs_process_attached in Vertical Tabs 6

2 calls to vertical_tabs_process_attached()
theme_vertical_tabs in ./vertical_tabs.module
After build function to add vertical tabs JS and CSS to the form.
vertical_tabs_add_vertical_tabs in ./vertical_tabs.module
Add a vertical tab form element to a form.

File

./vertical_tabs.module, line 416
Provides vertical tabs capability for fieldsets in forms.

Code

function vertical_tabs_process_attached($element) {
  $element += array(
    '#attached' => array(),
  );
  $element['#attached'] += array(
    'js' => array(),
    'css' => array(),
  );

  // Add any attached vertical tabs JavaScript.
  // Copied from form_process_attached() in Drupal 7.
  foreach (array(
    'js',
    'css',
  ) as $type) {
    foreach ($element['#attached'][$type] as $data => $options) {

      // If the value is not an array, it's a filename and passed as first
      // (and only) argument.
      if (!is_array($options)) {
        $data = $options;
        $options = array();
      }

      // In some cases, the first parameter ($data) is an array. Arrays can't be
      // passed as keys in PHP, so we have to get $data from the value array.
      if (is_numeric($data)) {
        $data = $options['data'];
        unset($options['data']);
      }
      $options += array(
        'type' => 'module',
      );
      if ($type == 'js') {
        drupal_add_js($data, $options['type']);
      }
      else {
        drupal_add_css($data, $options['type']);
      }
    }
  }
}