You are here

function uc_dropdown_attributes_form_uc_order_edit_form_alter in Dropdown Attributes 7

Same name and namespace in other branches
  1. 8 uc_dropdown_attributes.module \uc_dropdown_attributes_form_uc_order_edit_form_alter()

Implements hook_form_FORM_ID_alter() for uc_order_edit_form().

File

./uc_dropdown_attributes.module, line 769
Show/hide attributes based on the values of other attributes.

Code

function uc_dropdown_attributes_form_uc_order_edit_form_alter(&$form, &$form_state) {
  if (isset($form_state['products_action']) && $form_state['products_action'] == 'add_product') {
    $product_type = $form['product_controls']['node']['#value']->type;
    if ($product_type == 'product_kit') {
      foreach ($form['product_controls']['sub_products'] as $nid => $product) {
        if (is_numeric($nid)) {
          $type = uc_dropdown_attributes_dependency_type($nid);
          if (!is_null($type)) {
            uc_dropdown_attributes_order_product_alter($nid, $form['product_controls']['sub_products'][$nid]['attributes'], $type);
            if (!in_array('_uc_dropdown_attributes_order_product_kit_build', $form['#after_build'])) {
              $form['#after_build'][] = '_uc_dropdown_attributes_order_product_kit_build';
            }
          }
        }
      }
    }
    else {
      $nid = $form['product_controls']['node']['#value']->nid;
      $type = uc_dropdown_attributes_dependency_type($nid);
      if (!is_null($type)) {
        uc_dropdown_attributes_order_product_alter($nid, $form['product_controls']['attributes'], $type);
        $form['nid'] = array(
          '#type' => 'hidden',
          '#value' => $nid,
        );
        switch ($type) {
          case 'node':
            $form['#after_build'][] = '_uc_dropdown_attributes_order_product_build';
            break;
          case 'class':
            $form['#after_build'][] = '_uc_dropdown_attributes_order_class_build';
            break;
        }
      }
    }
  }
}