It seems counterintuitive that a second call to form_set_error('foo', ...) will overwrite any existing error message set for the element foo rather than adding another error message relating to it.

I came upon this while trying to improve the form validation for path_redirect, where it's possible that a hapless user might enter a redirection "from" path that is problematic in several different ways. (Yes, the help text could be improved!)

I tried doing something like:

form_set_error('foo', form_get_error('foo') . ' Bad foo detected.');

...but this causes an error @781 in form.inc.

What I propose is that an array of errors be stored for each element, and that successive calls to form_set_error append to that array. When rendering the errors, each error is displayed in the order they were added.

Sound reasonable? Is there a common workaround for this?

Comments

dave reid’s picture

Version: 6.x-dev » 7.x-dev
Category: feature » bug

This is a bug that calls to form_set_error() after the first one do not show at all. Setting to 7.x.

casey’s picture

dave reid’s picture

Status: Active » Closed (duplicate)

Well this one is the *first* issue, but let's merge it into #549020: form_set_error should accept multiple errors on one component.