Hi,

I created a content type and added an image field with the global settings "Required" and "Number of values: 1".

As the field is marked as "required", it should not be possible to create new content without uploading an image. Though, empty upload fields are not actually rejected.

My Drupal installation: CCK: 6.x-2.1, ImageField: 6x-3.0-beta2, Drupal 6.9

The FileField module seems to work perfectly.

Thank you for your help,
Andy

CommentFileSizeAuthor
#3 imagefield_required.patch824 bytesquicksketch

Comments

quicksketch’s picture

I can't reproduce this error. When marking an ImageField as required it is shown with the required asterisk and throws an error if the form is submitted without uploading an image. I'd suggest upgrading to the beta3 versions of Image/FileField and CCK 2.2, though I don't know of any specific changes that cause a change in this area.

quicksketch’s picture

From #412860: If required is ticked, user can still submit node if imagefield is blank (which is marked as duplicate):

I have just upgraded to:
FileField module to 6.x-3.0-beta3
ImageField module to 6.x-3.0-beta3

And noticed that the imagefield which has "required" ticked on the settings page is not being validated if a user submits the page without uploading an image. It allows users to submit the node even if they don't upload a image.

If I add a standard filefield file upload widget. Then the system does validate if the image field is left blank. Seem to me that imagefield and filefield share the same validate function.

I dont know if i should submit this bug to filefield or imagefield.

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new824 bytes

Ah, I see why I didn't reproduce the problem: My content type had not only an image field but also a file field on the form. The presence of the file field had the effect of checking the requiredness of all other file (or image) fields on the form.

The source of this problem was my use of "module_invoke()" on the FileField widget function, which makes variables not be passed by reference. Calling filefield_widget() directly lets FileField modify the $form variable and add the extra #validate function. I committed the attached patch which solves this problem.

ivan zugec’s picture

Patch works perfectly.

Thanks alot.

cheers,
Ivan

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Balbo’s picture

Is it possible I'm suffering the same issue with version 6.x-3.7 ?

gg4’s picture

Version: 6.x-3.0-beta2 » 6.x-3.10
Status: Closed (fixed) » Active

Experiencing this issue with 6.x-3.10

quicksketch’s picture

Status: Active » Closed (fixed)

Experiencing this issue with 6.x-3.10

I doubt this is the same issue (over 2 years later). Please open a new issue with detailed instructions on how to reproduce this problem, preferably from a clean install of Drupal.