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
Comment #1
dave reidThis is a bug that calls to form_set_error() after the first one do not show at all. Setting to 7.x.
Comment #2
casey commentedDuplicate #549020: form_set_error should accept multiple errors on one component?
Comment #3
dave reidWell this one is the *first* issue, but let's merge it into #549020: form_set_error should accept multiple errors on one component.