function cck_default_value_validate in Content Construction Kit (CCK) 7.3
Validation handler to store php default values.
1 string reference to 'cck_default_value_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 164 - 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_default_value_validate(&$form, &$form_state) {
$field = $form['#field'];
$instance = $form['#instance'];
$default_value_function = $form_state['values']['instance']['default_value_function'];
$php_code = $form_state['values']['instance']['default_value_php'];
if (!empty($php_code)) {
$default_value_function = 'cck_default_value_php';
}
elseif (empty($php_code) && $default_value_function == 'cck_default_value_php') {
$default_value_function = '';
}
form_set_value($form['instance']['default_value_widget']['default_value_function'], $default_value_function, $form_state);
// @todo This should be done at submit time, not validate.
cck_field_set_setting('default_value_php', 'instance', $php_code, $field, $instance);
}