Skip navigation
Help

hook_uc_form_alter

6 hooks.php hook_uc_form_alter(&$form, &$form_state, $form_id)
7 uc_store.api.php hook_uc_form_alter(&$form, &$form_state, $form_id)

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

hook_form_alter()

Related topics

2 functions implement hook_uc_form_alter()

1 invocation of hook_uc_form_alter()

File

ubercart/uc_store/uc_store.api.php, line 49
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'] = 'fieldset';
      }
    }
  }
  // If not, add attributes to the node.
  else {
    $form['attributes'] = _uc_attribute_alter_form($node);

    if (is_array($form['attributes'])) {
      $form['attributes']['#tree'] = TRUE;
      $form['attributes']['#weight'] = -1;
    }
  }
}