function uc_attribute_form_alter in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_attribute/uc_attribute.module \uc_attribute_form_alter()
Implements hook_form_alter().
File
- uc_attribute/
uc_attribute.module, line 306
Code
function uc_attribute_form_alter(&$form, $form_state, $form_id) {
if (strpos($form_id, 'add_product_form')) {
$node =& $form['node']['#value'];
// If the node has a product list, add attributes to them
if (isset($form['sub_products']) && count(element_children($form['sub_products']))) {
foreach (element_children($form['sub_products']) as $key) {
$form['sub_products'][$key]['attributes'] = _uc_attribute_alter_form(node_load($key));
if (is_array($form['sub_products'][$key]['attributes'])) {
$form['sub_products'][$key]['attributes']['#tree'] = TRUE;
$form['sub_products'][$key]['#type'] = 'fieldset';
}
}
}
else {
$form['attributes'] = _uc_attribute_alter_form($node);
if (is_array($form['attributes'])) {
$form['attributes']['#tree'] = TRUE;
$form['attributes']['#weight'] = -1;
}
}
}
}