You are here

function hook_uc_form_alter in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 uc_store/uc_store.api.php \hook_uc_form_alter()
  2. 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.

For a description of the hook parameters:

See also

hook_form_alter()

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

docs/hooks.php, line 1577
These are the hooks that are invoked by the Ubercart core.

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'] = 'fieldset';
      }
    }
  }
  else {
    $form['attributes'] = _uc_attribute_alter_form($node);
    if (is_array($form['attributes'])) {
      $form['attributes']['#tree'] = TRUE;
      $form['attributes']['#weight'] = -1;
    }
  }
}