function theme_uc_object_options_form in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_attribute/uc_attribute.module \theme_uc_object_options_form()
- 6.2 uc_attribute/uc_attribute.admin.inc \theme_uc_object_options_form()
Displays the option form.
Parameters
$variables: An associative array containing:
- form: A render element representing the form.
See also
File
- uc_attribute/
uc_attribute.admin.inc, line 1016 - Attribute administration menu items.
Code
function theme_uc_object_options_form($variables) {
$form = $variables['form'];
$output = '';
drupal_add_js('misc/tableselect.js');
$header = array(
array(
'data' => ' ' . t('Options'),
'class' => array(
'select-all',
),
),
t('Default'),
t('Cost'),
t('Price'),
t('Weight'),
t('List position'),
);
$tables = 0;
if (isset($form['attributes'])) {
foreach (element_children($form['attributes']) as $key) {
$rows = array();
foreach (element_children($form['attributes'][$key]['options']) as $oid) {
$rows[] = array(
'data' => 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']),
),
'class' => array(
'draggable',
),
);
}
$table_id = 'uc-attribute-option-table-' . $tables++;
drupal_add_tabledrag($table_id, 'order', 'sibling', 'uc-attribute-option-table-ordering');
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'class' => array(
'product_attributes',
),
'id' => $table_id,
),
'caption' => '<h2>' . drupal_render($form['attributes'][$key]['name']) . '</h2>',
'empty' => t('This attribute does not have any options.'),
));
}
}
if (!$tables) {
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_children($form);
return $output;
}