function conditional_fields_allowed_values in Conditional Fields 6.2
Same name and namespace in other branches
- 5 conditional_fields.module \conditional_fields_allowed_values()
Find the allowed values for a field
2 calls to conditional_fields_allowed_values()
- 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 618 - Content fields and groups visibility based on the values of user defined 'trigger' fields.
Code
function conditional_fields_allowed_values($field) {
static $options;
if (!isset($options[$field['field_name']])) {
$function = $field['module'] . '_allowed_values';
$options[$field['field_name']] = function_exists($function) ? $function($field) : content_allowed_values($field);
if (empty($options[$field['field_name']])) {
return FALSE;
}
// Add an empty allowed value to unrequired single value fields.
if (!$field['required'] && !$field['multiple']) {
$options[$field['field_name']] = array_merge(array(
'' => t('- None (empty value) -'),
), $options[$field['field_name']]);
}
// Strip tags, since we use a select, not the real widget.
foreach ($options[$field['field_name']] as $key => $label) {
$options[$field['field_name']][$key] = strip_tags($label);
}
}
return $options[$field['field_name']];
}