You are here

function _uc_dropdown_attributes_order_product_build in Dropdown Attributes 7

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

Form build for products for the order page.

Callback for $form['#after_build'] for products. Adds the CSS to hide the dependent attributes.

1 string reference to '_uc_dropdown_attributes_order_product_build'
uc_dropdown_attributes_form_uc_order_edit_form_alter in ./uc_dropdown_attributes.module
Implements hook_form_FORM_ID_alter() for uc_order_edit_form().

File

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

Code

function _uc_dropdown_attributes_order_product_build($form, &$form_state) {
  $nid = $form['nid']['#value'];
  $sql = 'SELECT aid, parent_aid, parent_values, required
    FROM {uc_dropdown_attributes} WHERE nid=:nid';
  $attributes = db_query($sql, array(
    ':nid' => $nid,
  ));
  if (isset($form_state['triggering_element'])) {
    $parents = $form_state['triggering_element']['#parents'];
    $parent_aid = $parents[count($parents) - 1];
    $parent_value = $form_state['triggering_element']['#value'];
    uc_dropdown_attributes_remove_values($parent_aid, $parent_value, $nid, 'node', $form_state['values']['product_controls']);
  }
  uc_dropdown_attributes_order_attribute_display($attributes, $form['product_controls']['attributes'], $form_state['values']['product_controls']['attributes']);
  return $form;
}