function uc_object_options_form_validate in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_attribute/uc_attribute.module \uc_object_options_form_validate()
- 6.2 uc_attribute/uc_attribute.admin.inc \uc_object_options_form_validate()
Makes sure that all selected default options are enabled.
See also
uc_object_options_form_submit()
File
- uc_attribute/
uc_attribute.admin.inc, line 1123 - Attribute administration menu items.
Code
function uc_object_options_form_validate($form, &$form_state) {
$error = FALSE;
if (isset($form_state['values']['attributes'])) {
foreach ($form_state['values']['attributes'] as $aid => $attribute) {
$selected_opts = array();
if (isset($attribute['options'])) {
foreach ($attribute['options'] as $oid => $option) {
if ($option['select'] == 1) {
$selected_opts[] = $oid;
}
}
}
if (!empty($selected_opts) && !isset($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');
}
}