You are here

function theme_uc_object_options_form in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_attribute/uc_attribute.module \theme_uc_object_options_form()
  2. 7.3 uc_attribute/uc_attribute.admin.inc \theme_uc_object_options_form()

Displays the option form.

See also

uc_object_options_form()

File

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

Code

function theme_uc_object_options_form($form) {
  $output = '';
  $header = array(
    array(
      'data' => '  ' . t('Options'),
    ) + theme('table_select_header_cell'),
    t('Default'),
    t('Cost'),
    t('Price'),
    t('Weight'),
    t('List position'),
  );
  $table_id_num = $tables = 0;
  if (isset($form['attributes'])) {
    foreach (element_children($form['attributes']) as $key) {
      $rows = array();
      if (element_children($form['attributes'][$key]['default'])) {
        foreach (element_children($form['attributes'][$key]['default']) as $oid) {
          $row = array(
            drupal_render($form['attributes'][$key]['options'][$oid]['select']),
            drupal_render($form['attributes'][$key]['default'][$oid]),
            drupal_render($form['attributes'][$key]['options'][$oid]['cost']),
            drupal_render($form['attributes'][$key]['options'][$oid]['price']),
            drupal_render($form['attributes'][$key]['options'][$oid]['weight']),
            drupal_render($form['attributes'][$key]['options'][$oid]['ordering']),
          );
          $rows[] = array(
            'data' => $row,
            'class' => 'draggable',
          );
        }
        $table_id = 'uc-attribute-option-table-' . $table_id_num++;
        drupal_add_tabledrag($table_id, 'order', 'sibling', 'uc-attribute-option-table-ordering');
      }
      else {
        $row = array();
        $row[] = array(
          'data' => drupal_render($form['attributes'][$key]['default']),
          'colspan' => 6,
        );
        $rows[] = $row;
      }
      if (!count($rows)) {
        $rows[] = array(
          array(
            'data' => t('This !type does not have any attributes.', array(
              '!type' => $form['type']['#value'] == 'product' ? t('product') : t('product class'),
            )),
            'colspan' => 6,
          ),
        );
      }
      $output .= theme('table', $header, $rows, array(
        'class' => 'product_attributes',
        'id' => $table_id,
      ), '<h2>' . drupal_render($form['attributes'][$key]['name']) . '</h2>');
      $tables++;
    }
  }
  if (!$tables) {
    $output .= '<br /><br />';
    if ($form['type']['#value'] == 'product') {
      drupal_set_message(t('This product does not have any attributes.'), 'warning');
    }
    else {
      drupal_set_message(t('This product class does not have any attributes.'), 'warning');
    }
  }
  $output .= drupal_render($form);
  return $output;
}