You are here

function views_bulk_operations_fields_action_validate in Views Bulk Operations (VBO) 6.3

Same name and namespace in other branches
  1. 6 actions/fields.action.inc \views_bulk_operations_fields_action_validate()

File

./fields.action.inc, line 207
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 ($form_state['values'][$field_name . '_check'] && isset($field['type'])) {
      $chosen++;
      $function = $field['module'] . '_field';
      if (function_exists($function)) {
        $form['#node']->{$field_name} = $form_state['values'][$field_name];
        $items = isset($form['#node']->{$field_name}) ? $form['#node']->{$field_name} : array();
        call_user_func($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.'));
  }
}