You are here

function user_badges_images_form_validate in User Badges 5

Same name and namespace in other branches
  1. 6.2 user_badges.admin.inc \user_badges_images_form_validate()
  2. 6 user_badges.admin.inc \user_badges_images_form_validate()

Validate the submission.

Check whether: Delete has been chosen AND a checkbox has been selected OR Upload has been chosen AND the file upload form is not empty.

File

./user_badges.module, line 440
@brief User Badges module file

Code

function user_badges_images_form_validate($form_id, $form_values) {
  if ($form_values['op'] == t('Upload') && file_check_upload('upload') === FALSE) {
    form_set_error('upload', t('Please enter the filename of an image to upload.'));
  }
  else {
    if ($form_values['op'] == t('Delete')) {
      if (count(array_filter($form_values['images'])) == 0) {
        form_set_error('images', t('Please select images to delete.'));
      }
    }
  }
}