You are here

function _uc_dropdown_attributes_order_class_build in Dropdown Attributes 7

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

Form build for classes for the order page.

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

1 string reference to '_uc_dropdown_attributes_order_class_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 919
Show/hide attributes based on the values of other attributes.

Code

function _uc_dropdown_attributes_order_class_build($form, &$form_state) {
  $sql = 'SELECT aid, parent_aid, parent_values, required
    FROM {uc_dropdown_classes} WHERE pcid=:pcid';
  $pcid = uc_dropdown_attributes_get_type($form['nid']['#value']);
  $attributes = db_query($sql, array(
    ':pcid' => $pcid,
  ));
  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'];

    // Note that values are stored in input, not values.
    uc_dropdown_attributes_remove_values($parent_aid, $parent_value, $pcid, 'class', $form_state['input']['product_controls']);
  }
  uc_dropdown_attributes_order_attribute_display($attributes, $form['product_controls']['attributes'], $form_state['values']['product_controls']['attributes']);
  return $form;
}