function views_bulk_operations_fields_action_validate in Views Bulk Operations (VBO) 6
Same name and namespace in other branches
- 6.3 fields.action.inc \views_bulk_operations_fields_action_validate()
1 call to views_bulk_operations_fields_action_validate()
File
- actions/
fields.action.inc, line 356 - Drupal action to set individual field values.
Code
function views_bulk_operations_fields_action_validate($form, $form_state) {
$chosen = 0;
foreach ($form['#field_info'] as $field_name => $field) {
if (empty($form_state['values'][$field_name . '_check'])) {
continue;
}
$chosen++;
if (!empty($form_state['values'][$field_name . '_code'])) {
continue;
}
if ($field['type'] == 'non_cck') {
if (is_array($field['validate'])) {
foreach ($field['validate'] as $function) {
if (!function_exists($function)) {
continue;
}
$function($form_state['values'][$field_name], $field);
}
}
}
else {
$function = $field['module'] . '_field';
if (!function_exists($function)) {
continue;
}
$form['#node']->{$field_name} = $form_state['values'][$field_name];
$items = isset($form['#node']->{$field_name}) ? $form['#node']->{$field_name} : array();
$function('validate', $form['#node'], $field, $items, $form, NULL);
content_field('validate', $form['#node'], $field, $items, $form, NULL);
}
}
if (!$chosen) {
form_set_error('', t('You must select at least one field to modify.'));
}
}