You are here

function theme_wunderground_weather_field_drag in Wunderground weather 7

Theme function to create draggable fields.

File

./wunderground_weather.module, line 116
Wunderground weather module to display weather forecasts and current weather conditions in blocks.

Code

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

  // Initialize the variable which will store table rows.
  $rows = array();

  // Iterate over each element in $form['fields'] array.
  foreach (element_children($form['fields'], TRUE) as $id) {
    $form['fields'][$id]['weight']['#attributes']['class'] = array(
      'field-item-weight',
    );
    $rows[] = array(
      'data' => array(
        drupal_render($form['fields'][$id]['name']),
        drupal_render($form['fields'][$id]['enabled']),
        drupal_render($form['fields'][$id]['weight']),
      ),
      'class' => array(
        'draggable',
      ),
    );
  }
  $header = array(
    t('Field'),
    t('Enabled'),
    t('Weight'),
  );
  $table_id = 'field-items-table';
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => $table_id,
    ),
  ));
  drupal_add_tabledrag($table_id, 'order', 'sibling', 'field-item-weight');
  return $output;
}