You are here

function fupload_list_images_imagefield_validate in Image FUpload 6.3

1 string reference to 'fupload_list_images_imagefield_validate'
fupload_list_images_imagefield in includes/images.previewlist.imagefield.inc

File

includes/images.previewlist.imagefield.inc, line 236

Code

function fupload_list_images_imagefield_validate($form, &$form_state) {

  // validation of some special parts
  $i = 0;
  $storage_mode = $form_state['values']['storage_mode'];
  $type = node_get_types('type', $form_state['values']['node_type']);
  foreach ($form_state['values']['image_items'] as $fid => $nid) {
    $i++;

    // load saved node(s)
    if ($storage_mode == "multiple" && empty($node) || $storage_mode == "single") {
      $node = node_load($nid);
    }

    // map some data to our $node to be able to do validation
    // taxonomy
    $node->taxonomy = $form_state['values']['taxonomy_' . $fid];

    // body field: if min_word_count set, check reality
    if (!empty($type->min_word_count) && isset($form_state['values']['node_body_' . $fid]) && count(explode(' ', $form_state['values']['node_body_' . $fid])) < $type->min_word_count) {
      form_set_error('node_body_' . $fid, t('The field %body_label of the @img_number. image is too short. You need at least %words words.', array(
        '%body_label' => $type->body_label,
        '@img_number' => $i,
        '%words' => $type->min_word_count,
      )));
    }

    // little hack: prevent that body field will be checked again
    unset($node->body);

    // call hook_validation
    node_validate($node);
  }
}