You are here

function uc_dropdown_attributes_class_submit in Dropdown Attributes 7

Same name and namespace in other branches
  1. 6 dependent_dropdown.inc \uc_dropdown_attributes_class_submit()

Form submission handler for uc_dropdown_attributes_class().

Write form values out to the database table.

File

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

Code

function uc_dropdown_attributes_class_submit($form, &$form_state) {
  if ($form_state['clicked_button']['#id'] == 'edit-submit') {
    $form_state['rebuild'] = FALSE;
    $pcid = $form_state['build_info']['args'][0];
    $values = $form_state['values']['attributes'];
    $attributes = _uc_dropdown_attributes_extract_attributes($values);
    $result = db_delete('uc_dropdown_classes')
      ->condition('pcid', $pcid)
      ->execute();
    drupal_set_message(t('Processing class :pcid', array(
      ':pcid' => $pcid,
    )));
    foreach ($attributes as $aid => $attribute) {
      if ($attribute->parent_aid != 0) {
        uc_dropdown_attributes_class_create_dependency($pcid, $aid, $attribute->parent_aid, $attribute->parent_values, $attribute->required);
        drupal_set_message(t('Saved :name', array(
          ':name' => $attribute->name,
        )));
      }
    }
  }

  // edit-next or anything else will cause rebuild.
  $form_state['rebuild'] = TRUE;
}