You are here

function uc_object_options_form_validate in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_attribute/uc_attribute.admin.inc \uc_object_options_form_validate()
  2. 7.3 uc_attribute/uc_attribute.admin.inc \uc_object_options_form_validate()

File

uc_attribute/uc_attribute.module, line 1107

Code

function uc_object_options_form_validate($form_id, $form_values, $form) {
  if (isset($form_values['attributes'])) {
    foreach ($form_values['attributes'] as $aid => $attribute) {
      $selected_opts = array();
      if (is_array($attribute['options'])) {
        foreach ($attribute['options'] as $oid => $option) {
          if ($option['select'] == 1) {
            $selected_opts[] = $oid;
          }
        }
      }
      if (!empty($selected_opts) && !$form['attributes'][$aid]['default']['#disabled'] && !in_array($attribute['default'], $selected_opts)) {
        form_set_error($attribute['default']);
        $error = TRUE;
      }
    }
  }
  if ($error) {
    drupal_set_message(t('All attributes with enabled options must specify an enabled option as default.'), 'error');
  }
}