[html-formfu] new default_args() method - deprecates
element_defaults()
Carl Franks
fireartist at gmail.com
Fri Aug 1 17:43:35 BST 2008
I've added a new default_args() method - which basically does what
element_defaults() did, but also for constraints, inflators, etc.
element_defaults() still works for now - it just passes it's args to
default_args()->{elements}
but it issues a warning, and will be removed in a future version.
Here's the POD for the new method:
=head2 default_args
Arguments: \%defaults
Set defaults which will be added to every element, constraint, etc. of the
listed type which is added to the form.
For example, to make every C<Text> element automatically have a
L<size|HTML::FormFu::Element/size> of C<10>, and make every C<Strftime>
deflator automatically get it's strftime set to C<%d/%m/%Y>:
element_args:
elements:
Text:
size: 10
deflators:
Strftime:
strftime: '%d/%m/%Y'
To take it even further, you can even make all DateTime elements automatically
get an appropriate Strftime deflator and a DateTime inflator:
element_args:
elements:
DateTime:
deflators:
type: Strftime
strftime: '%d-%m-%Y'
inflators:
type: DateTime
parser:
strptime: '%d-%m-%Y'
Note: Unlike the proper methods which have aliases, for example L</elements>
which is an alias for L</element> - the keys given to C<default_args> must
be of the plural form, e.g.:
element_args:
elements: {}
deflators: {}
filters: {}
constraints: {}
inflators: {}
validators: {}
transformers: {}
output_processors: {}
More information about the HTML-FormFu
mailing list