template_preprocess_field_ui_field_overview_form

Versions
7
template_preprocess_field_ui_field_overview_form(&$vars)

Theme preprocess function for field_ui-field-overview-form.tpl.php.

Code

modules/field_ui/field_ui.admin.inc, line 283

<?php
function template_preprocess_field_ui_field_overview_form(&$vars) {
  $form = &$vars['form'];

  drupal_add_css(drupal_get_path('module', 'field_ui') . '/field_ui.css');
  drupal_add_tabledrag('field-overview', 'order', 'sibling', 'field-weight');
  drupal_add_js(drupal_get_path('module', 'field_ui') . '/field_ui.js');
  // Add settings for the update selects behavior.
  $js_fields = array();
  foreach (field_ui_existing_field_options($form['#object_type'], $form['#bundle']) as $field_name => $fields) {
    $field = field_info_field($field_name);
    $instance = field_info_instance($form['#object_type'], $field_name, $form['#bundle']);
    $js_fields[$field_name] = array('label' => $instance['label'], 'type' => $field['type'], 'widget' => $instance['widget']['type']);
  }
  drupal_add_js(array('fieldWidgetTypes' => field_ui_widget_type_options(), 'fields' => $js_fields), 'setting');

  $order = _field_ui_overview_order($form, $form['#field_rows']);
  $rows = array();

  // Identify the 'new item' keys in the form.
  $keys = array_keys($form);
  $add_rows = array();
  foreach ($keys as $key) {
    if (substr($key, 0, 4) == '_add') {
      $add_rows[] = $key;
    }
  }
  while ($order) {
    $key = reset($order);
    $element = &$form[$key];
    $row = new stdClass();

    // Add target classes for the tabledrag behavior.
    $element['weight']['#attributes']['class'][] = 'field-weight';
    $element['hidden_name']['#attributes']['class'][] = 'field-name';
    // Add target classes for the update selects behavior.
    switch ($element['#row_type']) {
      case 'add_new_field':
        $element['type']['#attributes']['class'][] = 'field-type-select';
        $element['widget_type']['#attributes']['class'][] = 'widget-type-select';
        break;

      case 'add_existing_field':
        $element['field_name']['#attributes']['class'][] = 'field-select';
        $element['widget_type']['#attributes']['class'][] = 'widget-type-select';
        $element['label']['#attributes']['class'][] = 'label-textfield';
        break;
    }
    foreach (element_children($element) as $child) {
      $row->{$child} = drupal_render($element[$child]);
    }
    $row->label_class = 'label-' . strtr($element['#row_type'], '_', '-');
    $row->row_type = $element['#row_type'];
    $row->class = 'draggable';
    $row->class .= isset($element['#add_new']) ? ' add-new' : '';
    $row->class .= isset($element['#disabled_row']) ? ' menu-disabled' : '';

    $rows[] = $row;
    array_shift($order);
  }
  $vars['rows'] = $rows;
  $vars['submit'] = drupal_render_children($form);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.