The 'required field' validation rule for an image column fails regardless of whether or not an image has been uploaded. The desired behavior is that image columns should only be required if an image has been uploaded. This issue affects all image columns: fid, alt, title, width, height.

Steps to reproduce:

  1. Create an 'image' field on a content type
  2. Set the 'number of values' to 1
  3. Enable 'alt' field on the 'image' field
  4. Create a 'required field' validation rule for the 'image' field
  5. Require the 'alt' column
  6. Add content of specified content type
  7. Save without uploading an image.

Validation will fail. The node cannot be saved. This same issue manifests itself on multi-value image fields. In this case, a node can never be saved.

My specific use case is the client wishes to require alt text on images.

Comments

g089h515r806’s picture

You could use PHP code validator, and using following code:

if(!empty($this->item['fid']) && $this->value===''){
  $this->set_error();
}

Or you could write your own validator.

g089h515r806’s picture

Category: bug » feature

change it to feature request.

chris burge’s picture

Provided PHP validation rule works like a charm. Thanks!

g089h515r806’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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