You are here

function theme_uc_attribute_options_form in Ubercart 6.2

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

Formats an attribute and its options.

File

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

Code

function theme_uc_attribute_options_form($form) {
  $header = array(
    t('Name'),
    t('Default cost'),
    t('Default price'),
    t('Default weight'),
    array(
      'data' => t('List position'),
      'sort' => 'asc',
    ),
    t('Operations'),
  );
  if (count(element_children($form['options'])) > 0) {
    foreach (element_children($form['options']) as $oid) {
      $row = 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]['ops']),
      );
      $rows[] = array(
        'data' => $row,
        'class' => 'draggable',
      );
    }
  }
  else {
    $rows[] = array(
      array(
        'data' => t('No options for this attribute have been added yet.'),
        'colspan' => 6,
      ),
    );
  }
  drupal_add_tabledrag('uc-attribute-option-table', 'order', 'sibling', 'uc-attribute-option-table-ordering');
  $output = theme('table', $header, $rows, array(
    'id' => 'uc-attribute-option-table',
  ));
  $output .= drupal_render($form);
  $output .= l(t('Add an option'), 'admin/store/attributes/' . $form['aid']['#value'] . '/options/add');
  return $output;
}