You are here

function theme_uc_attribute_options_form in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_attribute/uc_attribute.admin.inc \theme_uc_attribute_options_form()

Formats an attribute and its options.

Parameters

$variables: An associative array containing:

  • form: A render element representing the form.

File

uc_attribute/uc_attribute.admin.inc, line 323
Attribute administration menu items.

Code

function theme_uc_attribute_options_form($variables) {
  $form = $variables['form'];
  $header = array(
    t('Name'),
    t('Default cost'),
    t('Default price'),
    t('Default weight'),
    array(
      'data' => t('List position'),
      'sort' => 'asc',
    ),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $rows = array();
  foreach (element_children($form['options']) as $oid) {
    $rows[] = array(
      'data' => array(
        drupal_render($form['options'][$oid]['name']),
        drupal_render($form['options'][$oid]['cost']),
        drupal_render($form['options'][$oid]['price']),
        drupal_render($form['options'][$oid]['weight']),
        drupal_render($form['options'][$oid]['ordering']),
        drupal_render($form['options'][$oid]['edit']),
        drupal_render($form['options'][$oid]['delete']),
      ),
      'class' => array(
        'draggable',
      ),
    );
  }
  drupal_add_tabledrag('uc-attribute-option-table', 'order', 'sibling', 'uc-attribute-option-table-ordering');
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'uc-attribute-option-table',
    ),
    'empty' => t('No options for this attribute have been added yet.'),
  ));
  $output .= drupal_render_children($form);
  return $output;
}