function content_rules_action_populate_field_validate in Content Construction Kit (CCK) 6.3
Same name and namespace in other branches
- 6.2 includes/content.rules.inc \content_rules_action_populate_field_validate()
Validate the chosen value or php code.
1 call to content_rules_action_populate_field_validate()
File
- includes/
content.rules.inc, line 121 - Provides basic rules module support.
Code
function content_rules_action_populate_field_validate($form, &$form_state) {
if (!isset($form_state['element']['#settings']['field_name'])) {
//Just validate the last step.
return;
}
if (isset($form_state['values']['code']) && ($php = $form_state['values']['code'])) {
if (strpos($php, 'return') === FALSE) {
form_set_error('code', t('You have to return the default value in the expected format.'));
}
}
else {
// Validate the field.
$settings = $form_state['element']['#settings'];
$field = content_fields($settings['field_name']);
$field_types = _content_field_types();
$function = $field_types[$field['type']]['module'] . '_field';
if (function_exists($function)) {
$form['#node'] = (object) array(
'type' => '',
$settings['field_name'] => $form_state['values'][$settings['field_name']],
);
$items = isset($form['#node']->{$field}['field_name']) ? $form['#node']->{$field}['field_name'] : array();
//Make sure AHAH 'add more' button isn't sent to the fields
// for processing.
unset($items[$field['field_name'] . '_add_more']);
$function('validate', $form['#node'], $field, $items, $form, NULL);
content_field('validate', $form['#node'], $field, $items, $form, NULL);
}
}
}