You are here

function _uc_dropdown_attributes_extract_attributes in Dropdown Attributes 7

Helper function extracting data from the administration form into an array.

Extracts information for the attributes from the administration form into an array to prepare for insertion into a database table.

Parameters

array $values: The attributes array from the values stored in the $form_state array.

Return value

array An array of attribute information.

2 calls to _uc_dropdown_attributes_extract_attributes()
uc_dropdown_attributes_class_submit in ./dependent_dropdown.inc
Form submission handler for uc_dropdown_attributes_class().
uc_dropdown_attributes_product_submit in ./dependent_dropdown.inc
Form submission handler for uc_dropdown_attributes_product().

File

./dependent_dropdown.inc, line 334
Administrative interface for specifying the attribute dependencies.

Code

function _uc_dropdown_attributes_extract_attributes($values) {
  $attributes = array();
  foreach ($values as $aid => $value) {
    if (!isset($attributes[$aid])) {
      $attributes[$aid] = new stdClass();
    }
    $attribute = uc_attribute_load($aid);
    $attributes[$aid]->name = $attribute->name;
    foreach ($value as $field => $field_value) {
      switch ($field) {
        case 'parent':
          $attributes[$aid]->parent_aid = $field_value;
          break;
        case 'values':
          $attributes[$aid]->parent_values = $field_value;
          break;
        case 'required':
          $attributes[$aid]->required = $field_value;
          break;
      }
    }
  }
  return $attributes;
}