You are here

function theme_search_autocomplete_treelist_form in Search Autocomplete 7.3

Same name and namespace in other branches
  1. 6.4 search_autocomplete.form.treelist.inc \theme_search_autocomplete_treelist_form()
  2. 6.2 search_autocomplete.form.treelist.inc \theme_search_autocomplete_treelist_form()
  3. 7.4 search_autocomplete.form.treelist.inc \theme_search_autocomplete_treelist_form()
  4. 7.2 search_autocomplete.form.treelist.inc \theme_search_autocomplete_treelist_form()

CALLBACK: Theme function for this treelist form

File

./search_autocomplete.form.treelist.inc, line 134
Search Autocomplete Display the list of form to autocomplete and themis it as a draggable table.

Code

function theme_search_autocomplete_treelist_form($variables) {
  $form = $variables['form'];
  drupal_add_tabledrag('my-draggable-table', 'order', 'sibling', 'weight-group');
  drupal_add_tabledrag('my-draggable-table', 'match', 'parent', 'parent-group', 'parent-group', 'id-group');
  $rows = array();

  // for each elements to anchor in the form
  foreach (element_children($form['my_items']) as $key) {
    $element =& $form['my_items'][$key];
    $element['weight']['#attributes']['class'] = array(
      'weight-group',
    );
    $element['fid']['#attributes']['class'] = array(
      'id-group',
    );
    $element['parent_fid']['#attributes']['class'] = array(
      'parent-group',
    );
    $rows[] = array(
      'data' => array(
        theme('indentation', array(
          'size' => $element['#depth'],
        )) . drupal_render($element['title']),
        drupal_render($element['enabled']),
        drupal_render($element['weight']) . drupal_render($element['fid']) . drupal_render($element['parent_fid']),
        drupal_render($element['operations']['configure']),
        drupal_render($element['operations']['delete']),
      ),
      'class' => array(
        'draggable',
      ),
    );
  }

  // create table headers
  $header = array(
    t('Form nam'),
    t('Enabled'),
    t('Weight'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );

  // Themize the table and render the form
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'my-draggable-table',
    ),
  ));
  $output .= drupal_render_children($form);
  $output .= drupal_render($form['submit']);
  return $output;
}