[html-formfu] Prefixing error messages
Carl Franks
fireartist at gmail.com
Tue Mar 1 14:37:16 GMT 2011
On 1 March 2011 14:04, Matthias Dietrich <perl at rainboxx.de> wrote:
> Hi,
>
> I'm using FormFu with Catalyst and I'm i18n'ing all labels and error messages.
>
> On my registration form a user has to enter a password and repeat it in another input field. I use the Equal constraint here so the form is invalid if the both field values are not equal. The error message by FormFu is then whatever "form_constraint_equal" is i18n'ed to. This is fine in the first step.
>
> However, when using such a constraint on more than one form I want to address the issue in context to the form. On the registration form I may want to say something like "Your passwords have to be equal" and on another form "Your email address has to be the same as ...". The Equal constraint is only one example.
>
> Is there a possibility to prefix the i18n tag with something, so that the message "form_constraint_equal" will be like "Registration.form_constraint_equal" on the registration form and "Newsletter.form_constraint_equal" on a newsletter form?
Hi,
Each constraint can override the error message with message_loc()
I'd suggest something like:
elements:
- type: Password
name: password
constraints:
- type: Equal
others: password_repeat
message_loc: form_constraint_equal_password
- type: Password
name: password_repeat
Carl
More information about the HTML-FormFu
mailing list