[html-formfu] error message changes + new constraints + I18N author
update request
Carl Franks
fireartist at gmail.com
Wed Sep 17 12:35:15 BST 2008
All I18N error strings can contain placeholders such as [_1], [_2],
etc - this allows error messages to provide more accurate feedback.
The values used in these placeholders are set by
$constraint->localize_args() - but until now, only a couple of
constraints automatically set this.
Now, the Length, Range and File::Size constraints pass both their
min() and max() values - and their error messages have been changed to
the form:
Length: Must be between [_1] and [_2] characters long
Range: Must be between [_1] and [_2]
File::Size: File-size must be between [_1] and [_2] bytes
If you're not using both min() and max(), you should use one of the
more specific constraints:
MinLength
MaxLength
MinRange
MaxRange
File::MinSize
File::MaxSize
These constraints only pass their appropriate min() or max() values -
and so have more specific error messages, like so:
File::MinSize: File-size must be at least [_1] bytes
The DependOn and Equal constraints now set localize_args() to the
label() of the field that the constraint is attached to.
So, for example, if you have the following form:
elements:
- type: Password
name: pass
label: Password
constraints:
- type: Equal
others: [pass2]
- type: Password
name: pass2
label: 'Repeat Password'
If the 2 submitted passwords differ, by default the error message will
be attached to the 2nd field (the one named in 'others'), and the
error message will read:
Does not match 'Password' value
I've also updated the error messages for the ASCII, Printable, and
Word constraints.
Unfortunately, I don't think there's any way to automate more specific
error messages for the following constraints:
AllOnNone, AutoSet, Callback, DateTime, Regex, Set
or for the inflators.
So you'll continue to have to set your own appropriate message() on
each of these constraints.
However, these changes mean you should need to set your own error
messages a lot less frequently than previously.
Could anyone who's submitted non-english I18N files, please try to
update them - both to take advantage of these changes, and to add
messages for any new constraints.
Cheers,
Carl
More information about the HTML-FormFu
mailing list