function cck_allowed_values_validate in Content Construction Kit (CCK) 7.3
Validation handler to store php allowed values.
1 string reference to 'cck_allowed_values_validate'
- cck_form_alter in ./
cck.module - Add fields to allowed values form to allow users to input a function or a PHP snippet that will return the allowed values.
File
- ./
cck.module, line 145 - Allows administrators to use php code snippets to define allowed values or default values. The snippets are stored in a database table and retrieved in callback functions.
Code
function cck_allowed_values_validate(&$form, &$form_state) {
$field = $form['#field'];
$php_code = $form_state['values']['field']['settings']['allowed_values_php'];
$allowed_values_function = $form_state['values']['field']['settings']['allowed_values_function'];
if (!empty($php_code)) {
$allowed_values_function = 'cck_allowed_values_php';
}
elseif (empty($php_code) && $allowed_values_function == 'cck_allowed_values_php') {
$allowed_values_function = '';
}
form_set_value($form['field']['settings']['allowed_values_function'], $allowed_values_function, $form_state);
// @todo This should be done at submit time, not validate.
cck_field_set_setting('allowed_values_php', 'field', $php_code, $field);
}