When using a group of validation rules for checking that at least one of several fields is not empty, the error message is displayed more than once if the validation fails.

Comments

b-prod’s picture

Status: Active » Needs review
StatusFileSize
new1.85 KB

The patch below fixes such issue. But due to a Drupal core bug that is discussed here (#289452: FAPI: Error class is not set if error message is empty), the following patch against Drupal core need to be applied: http://drupal.org/node/289452#comment-3039426.

The question is: should we test that the patch has been applied and provide a fallback behavior if not?
It could be quite simple by calling form_get_error($element) after havin thrown an empty message. If it return an empty string, we can consider that the patch was not applied anf call again form_error() with the message.

But I am not sure that adding more code to handle Drupal core issue is a good thing. Moreover, only the "one of several" validation rules are concerned by this Drupal bug.

Anonymous’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Hi B-Prod, thanks for providing a patch for this. Unfortunately it does not apply to 7.x-2.x-dev - any chance you could re-roll it?

FreeFox’s picture

I want to second this request. However, patching the core is 1 thing I'm not allowed to do. Is it possible to patch only the validation module to do the trick?

Thanks in advance. Keep up the good work.

b-prod’s picture

Issue summary: View changes
StatusFileSize
new2.56 KB

This patch applies against current DEV version.

Note that this patch still needs the patch against Drupal Core.

phily’s picture

A cleaner solution avoiding patching is suggested by ialexandri at https://www.drupal.org/node/2085103