I got a field with multiple value for image wich is required. If I delete the first image and I submit, a message error of requierd appear.
I make this in validate function of my form

  if(count($form_state ['values']['field_photos'] [LANGUAGE_NONE])==1  && (isset($form_state ['values']['field_photos'] [LANGUAGE_NONE][0]['fid']) && $form_state ['values']['field_photos'] [LANGUAGE_NONE][0]['fid']==0))
    form_set_error('field_photos',t('Photos obligatoires'));

Comments

musa.thomas’s picture

Issue summary: View changes

change code

phil_l’s picture

I have the same problem. While my multiple image field is required i am not allowed to delete the first image unless i want the "field is required" error message.
When i set the field to not required deleting images works just fine.
So i took a look into the module's code and it seems like the image field validation needs more conditions to work properly.

function plup_validate_element($element, &$form_state, $form) {
  if ($element['#required'] == TRUE && $element['#value'][0]['fid'] == 0) {
    form_error($element, t("@field field is required.", array('@field' => $element['#title'])));
  }
Anonymous’s picture

Status: Active » Closed (fixed)

Fixed in latest dev.

Anonymous’s picture

Issue summary: View changes

change code