You are here

function theme_dynamic_background_admin_weight_form in Dynamic Background 7

Same name and namespace in other branches
  1. 7.2 includes/weight.admin.inc \theme_dynamic_background_admin_weight_form()

Theme function for the weight administration form.

File

includes/weight.admin.inc, line 92
Hanldes the re-ordring of dynamic background extension weights to determind overrid order.

Code

function theme_dynamic_background_admin_weight_form($variables) {
  $form = $variables['form'];

  // Loop over the form elements and convert them into table rows.
  foreach (element_children($form['module']) as $id) {
    $form['module'][$id]['weight']['#attributes']['class'] = array(
      'db-weight',
    );
    $rows[] = array(
      'data' => array(
        drupal_render($form['module'][$id]['name']),
        drupal_render($form['module'][$id]['weight']),
      ),
      // Add class to make the row draggable
      'class' => array(
        'draggable',
      ),
    );
  }

  // Define the header.
  $header = array(
    t('Name'),
    t('Weight'),
  );

  // Render the table and the rest of the form.
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'db-weight-table',
    ),
  ));
  $output .= drupal_render_children($form);

  // Make the table draggable.
  drupal_add_tabledrag('db-weight-table', 'order', 'sibling', 'db-weight');
  return $output;
}