function conditional_fields_content_admin_field_validate in Conditional Fields 6.2
Same name and namespace in other branches
- 5 conditional_fields.module \conditional_fields_content_admin_field_validate()
- 6 conditional_fields.module \conditional_fields_content_admin_field_validate()
Check selection of values
2 string references to 'conditional_fields_content_admin_field_validate'
- conditional_fields_content_admin_field in ./
conditional_fields.module - Alteration of the field editing form
- conditional_fields_fieldgroup_group_edit_form in ./
conditional_fields.module - Alteration of the fieldgroup editing form
File
- ./
conditional_fields.module, line 576 - Content fields and groups visibility based on the values of user defined 'trigger' fields.
Code
function conditional_fields_content_admin_field_validate($form, &$form_state) {
if ($form_state['values']['conditional_fields']['available_fields']) {
$count_selected = 0;
foreach ($form_state['values']['conditional_fields']['available_fields'] as $available_field => $trigger_values) {
// Disallow selecting "Not controlling" and values at the same time
if (!empty($trigger_values['conditional_field_no_value']) && count($trigger_values) > 1) {
form_set_error('conditional_fields][' . $available_field, t('You cannot select "Not controlling" and other values at the same time.'));
}
// Disallow selecting "None (empty value)" and values at the same time.
if (isset($trigger_values['']) && count($trigger_values) > 1) {
form_set_error('conditional_fields][' . $available_field, t('You cannot select "None (empty value)" and other values at the same time.'));
}
}
}
else {
// Warn user on allowed values change
if (!$GLOBALS['content_copy'] && !empty($form['#controlled_fields']) && $form_state['values']['allowed_values'] != $form_state['#field_info'][$form['values']['field_name']]['allowed_values']) {
drupal_set_message(t('If you changed or removed any allowed value from the field, you might have to review its controlled fields and fieldgroups settings.'), 'warning');
}
}
}