Skip navigation
Help

theme_uc_attribute_options_form

6 uc_attribute.admin.inc theme_uc_attribute_options_form($form)
7 uc_attribute.admin.inc theme_uc_attribute_options_form($variables)

Formats an attribute and its options.

Parameters

$variables: An associative array containing:

  • form: A render element representing the form.

Related topics

File

ubercart/uc_attribute/uc_attribute.admin.inc, line 321
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;
}