function uc_dropdown_attributes_order_attribute_display in Dropdown Attributes 7
Same name and namespace in other branches
- 8 uc_dropdown_attributes.module \uc_dropdown_attributes_order_attribute_display()
Alter display of attributes on the oder page.
Parameters
array $attributes: Array of attribute dependency objects.
array &$form_attributes: Attributes part of the product form.
array $form_state_attributes: Attributes part of the product form_state.
3 calls to uc_dropdown_attributes_order_attribute_display()
- _uc_dropdown_attributes_order_class_build in ./
uc_dropdown_attributes.module - Form build for classes for the order page.
- _uc_dropdown_attributes_order_product_build in ./
uc_dropdown_attributes.module - Form build for products for the order page.
- _uc_dropdown_attributes_order_product_kit_build in ./
uc_dropdown_attributes.module - Form build for product kits for the order page.
File
- ./
uc_dropdown_attributes.module, line 1009 - Show/hide attributes based on the values of other attributes.
Code
function uc_dropdown_attributes_order_attribute_display($attributes, &$form_attributes, $form_state_attributes) {
foreach ($attributes as $attribute) {
$parent_value = $form_state_attributes[$attribute->parent_aid];
if ($parent_value) {
// A value has been entered in parent attribute.
$values = unserialize($attribute->parent_values);
if (array_key_exists($parent_value, $values)) {
// Show dependent attribute.
if ($attribute->required) {
$form_attributes[$attribute->aid]['#required'] = TRUE;
}
}
else {
// Hide dependent attribute.
$form_attributes[$attribute->aid]['#post_render'][] = 'uc_dropdown_attributes_post_render';
if ($attribute->required && $form_attributes[$attribute->aid]['#value'] != '') {
$form_attributes[$attribute->aid]['#value'] = '';
}
}
}
else {
$form_attributes[$attribute->aid]['#post_render'][] = 'uc_dropdown_attributes_post_render';
if ($attribute->required && $form_attributes[$attribute->aid]['#value'] != '') {
$form_attributes[$attribute->aid]['#value'] = '';
}
}
}
}