function uc_attribute_option_form in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_attribute/uc_attribute.admin.inc \uc_attribute_option_form()
- 7.3 uc_attribute/uc_attribute.admin.inc \uc_attribute_option_form()
Form builder for attribute options.
See also
uc_attribute_option_form_validate
uc_attribute_option_form_submit
2 string references to 'uc_attribute_option_form'
- uc_attribute_menu in uc_attribute/
uc_attribute.module - Implementation of hook_menu().
- uc_importer_import in uc_importer/
uc_importer.module - Imports an XML document into the database.
File
- uc_attribute/
uc_attribute.module, line 590
Code
function uc_attribute_option_form($aid, $oid = NULL) {
$attribute = uc_attribute_load($aid);
// If we got a bunk attribute ID, kick out an error message.
if (empty($attribute)) {
drupal_set_message(t('There is no attribute with that ID.'), 'error');
drupal_goto('admin/store/products/attributes');
}
$form['aid'] = array(
'#type' => 'hidden',
'#value' => $aid,
);
if ($oid) {
$option = $attribute->options[$oid];
if (!empty($option)) {
$form['oid'] = array(
'#type' => 'hidden',
'#value' => $oid,
);
drupal_set_title(t('Edit option: %name', array(
'%name' => $option->name,
)));
}
}
else {
drupal_set_title(t('Options for %name', array(
'%name' => $attribute->name,
)));
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('This name will appear to customers on product add to cart forms.'),
'#default_value' => $option->name,
'#required' => TRUE,
'#weight' => 0,
);
$form['ordering'] = array(
'#type' => 'weight',
'#title' => t('Order'),
'#description' => t('Options will be listed sorted by this value and then by their name.<br />May be overridden at the product level.'),
'#default_value' => $option->ordering,
'#weight' => 4,
);
$form['adjustments'] = array(
'#type' => 'fieldset',
'#title' => t('Default adjustments'),
'#description' => t('Enter a positive or negative value for each adjustment applied when this option is selected.<br />Any of these may be overriden at the product level.'),
'#collapsible' => FALSE,
'#weight' => 8,
);
$form['adjustments']['cost'] = array(
'#type' => 'textfield',
'#title' => t('Cost'),
'#default_value' => $option->cost,
'#weight' => 1,
);
$form['adjustments']['price'] = array(
'#type' => 'textfield',
'#title' => t('Price'),
'#default_value' => $option->price,
'#weight' => 2,
);
$form['adjustments']['weight'] = array(
'#type' => 'textfield',
'#title' => t('Weight'),
'#default_value' => $option->weight,
'#weight' => 3,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#suffix' => l(t('Cancel'), 'admin/store/products/attributes/' . $aid . '/options'),
'#weight' => 10,
);
return $form;
}