function uc_attribute_options_form in Ubercart 6.2
Same name and namespace in other branches
- 7.3 uc_attribute/uc_attribute.admin.inc \uc_attribute_options_form()
Displays options and the modifications to products they represent.
See also
uc_attribute_options_form_validate()
uc_attribute_options_form_submit()
1 string reference to 'uc_attribute_options_form'
- uc_attribute_menu in uc_attribute/
uc_attribute.module - Implements hook_menu().
File
- uc_attribute/
uc_attribute.admin.inc, line 336 - Attribute administration menu items.
Code
function uc_attribute_options_form($form_state, $attribute) {
$form = array();
// Set an appropriate title.
drupal_set_title(t('Options for %name', array(
'%name' => $attribute->name,
)));
// Store the attribute ID in the form array.
$form['aid'] = array(
'#type' => 'value',
'#value' => $attribute->aid,
);
$context = array(
'revision' => 'themed',
'type' => 'attribute_option',
'subject' => array(
'attribute' => $attribute,
),
);
$form['options'] = array();
// Loop through all the options on an attribute.
foreach ($attribute->options as $key => $data) {
$form['options'][$key] = array(
'name' => array(
'#value' => check_plain($data->name),
),
'cost' => array(
'#value' => $data->cost,
),
'price' => array(
'#value' => $data->price,
),
'weight' => array(
'#value' => $data->weight,
),
'ordering' => array(
'#type' => 'weight',
'#delta' => 50,
'#default_value' => $data->ordering,
'#attributes' => array(
'class' => 'uc-attribute-option-table-ordering',
),
),
'ops' => array(
'#value' => l(t('edit'), 'admin/store/attributes/' . $attribute->aid . '/options/' . $key . '/edit') . ' ' . l(t('delete'), 'admin/store/attributes/' . $attribute->aid . '/options/' . $key . '/delete'),
),
);
$context['subject']['option'] = $data;
$context['field'] = 'cost';
$form['options'][$key]['cost']['#value'] = uc_price($data->cost, $context);
$context['field'] = 'price';
$form['options'][$key]['price']['#value'] = uc_price($data->price, $context);
}
if (count($form['options'])) {
$form['options']['#tree'] = TRUE;
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save changes'),
'#weight' => 10,
);
}
return $form;
}