[html-formfu] How to override standard message, 'This field is required'?

Carl Franks fireartist at gmail.com
Thu Mar 26 08:52:27 GMT 2009


2009/3/25 Gordon Yeong <anexiole at gmail.com>:
> Hi,
>
>    Been using html::formfu for abit. Love the validation and configurability
> behind it:)
>
> got a very interesting question: How to override standard message, 'This
> field is required'?
>
> This is the message the comes up when you hit "submit" with an incomplete
> form.
> Those fields that are required which are left blank will have this message,
> 'This field is required' displayed.

You can also create your own I18N class to override the default
messages, so you don't need to put them in your form config.

The Localize stuff doesn't seem to be very well tested, though - and I
can't find a way to set it up from a config file, other than
'localize_class', which will mean you have to define *all* messages in
your own class, as you'll lose the default FormFu messages.

I'm not sure why add_localize_object() adds the object to the end of
an array - this means you can't override default FormFu messages, you
can only supplement them.
I'd suggest we change this, to add it to the start of the array.

I'd also suggest we add a add_localize_class(), so it can be called
from a config file, such as:
    add_localize_class: 'MyApp::I18N'

Has anyone been using the I18N methods, and want to chip in?

I'm also not sure why add_localize_object() expects an object for a
specific language, where_as 'localize_class' correctly expects the
base-class, and sets it up with $form->languages()
Barely any of this is currently tested, so I'd be quite happy to break
that if it would improve its usability.

Carl



More information about the HTML-FormFu mailing list