function hook_uc_form_alter in Ubercart 8.4
Same name and namespace in other branches
- 6.2 docs/hooks.php \hook_uc_form_alter()
- 7.3 uc_store/uc_store.api.php \hook_uc_form_alter()
Allows modules to modify forms before Drupal invokes hook_form_alter().
This hook will normally be used by core modules so any form modifications they make can be further modified by contrib modules using a normal hook_form_alter(). At this point, drupal_prepare_form() has not been called, so none of the automatic form data (e.g.: #parameters, #build_id, etc.) has been added yet.
See also
2 functions implement hook_uc_form_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- uc_attribute_uc_form_alter in uc_attribute/
uc_attribute.module - Implements hook_uc_form_alter().
- uc_product_kit_uc_form_alter in uc_product_kit/
uc_product_kit.module - Implements hook_uc_form_alter().
1 invocation of hook_uc_form_alter()
- uc_form_alter in uc_store/
uc_store.module - Executes hook_uc_form_alter() implementations.
File
- uc_store/
uc_store.api.php, line 27 - Hooks provided by the Store module.
Code
function hook_uc_form_alter(&$form, &$form_state, $form_id) {
// If the node has a product list, add attributes to them.
if (isset($form['products']) && count(Element::children($form['products']))) {
foreach (Element::children($form['products']) as $key) {
$form['products'][$key]['attributes'] = _uc_attribute_alter_form(Node::load($key));
if (is_array($form['products'][$key]['attributes'])) {
$form['products'][$key]['attributes']['#tree'] = TRUE;
$form['products'][$key]['#type'] = 'details';
}
}
}
else {
$form['attributes'] = _uc_attribute_alter_form($node);
if (is_array($form['attributes'])) {
$form['attributes']['#tree'] = TRUE;
$form['attributes']['#weight'] = -1;
}
}
}