function uc_attribute_form in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_attribute/uc_attribute.admin.inc \uc_attribute_form()
- 7.3 uc_attribute/uc_attribute.admin.inc \uc_attribute_form()
Form builder for product attributes.
See also
uc_attribute_form_validate
uc_attribute_form_submit
2 string references to 'uc_attribute_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 449
Code
function uc_attribute_form($aid = NULL) {
// If an attribute ID is specified, load it and add its ID as a hidden value.
$attribute = uc_attribute_load($aid);
if (!empty($attribute)) {
$form['aid'] = array(
'#type' => 'hidden',
'#value' => $aid,
);
drupal_set_title(t('Edit attribute: %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' => $attribute->name,
'#required' => TRUE,
);
$form['description'] = array(
'#type' => 'textfield',
'#title' => t('Help text'),
'#description' => t('<b>Optional.</b> Enter the help text that will display beneath the attribute on product add to cart forms.'),
'#default_value' => $attribute->description,
'#maxlength' => 255,
);
$form['required'] = array(
'#type' => 'checkbox',
'#title' => t('Make this attribute required, forcing the customer to choose an option.'),
'#description' => t('Selecting this for an attribute will disregard any default option you specify.<br />May be overridden at the product level.'),
'#default_value' => $attribute->required,
);
$form['display'] = array(
'#type' => 'select',
'#title' => t('Display type'),
'#description' => t('This specifies how the options for this attribute will be presented.<br />May be overridden at the product level.'),
'#options' => _uc_attribute_display_types(),
'#default_value' => isset($attribute->display) ? $attribute->display : 1,
);
$form['ordering'] = array(
'#type' => 'weight',
'#title' => t('Order'),
'#description' => t('Multiple attributes on an add to cart form are sorted by this value and then by their name.<br />May be overridden at the product level.'),
'#default_value' => $attribute->ordering,
);
$form['op'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#suffix' => l(t('Cancel'), 'admin/store/products/attributes'),
);
return $form;
}