Hi,
I have installed IMAGE module and tried to create image for image gallery. But without uploading an image the form submits. I already set the "required" attributes in image.moduel file, please see the below codes.

$form['image'] = array(
'#type' => 'file',
'#title' => t('Image'),
'#size' => 40,
'#required' => TRUE,
'#description' => t('Click "Browse..." to select an image to upload.'),
'#weight' => -3,
);

After this change, without uploading an image file it is showing an error and after uploading an image also it is showing the same error "image field is required".

please help me, how can I make image upload field mandatory?

Comments

scoorch’s picture

You could add your own function with $form['#validate'][]='your_function_name' and check manually whether an image has been uploaded... just an idea

knick08’s picture

I am also wondering the same thing as the original poster. Can anyone suggest a solution for this?

revnoah’s picture

updating the modules fixed the issue, even though I didn't see it in the release notes

saiprasad kandavalli’s picture

Add $form['#attributes']['enctype'] = 'multipart/form-data'; to ur form