[html-formfu] default_args for base classes

Daniel Hilton danhiruton at gmail.com
Fri May 7 17:13:29 GMT 2010


On Fri, May 7, 2010 at 9:00 AM, Carl Franks <fireartist at gmail.com> wrote:
> On 5 May 2010 00:12, Daniel Hilton <danhiruton at gmail.com> wrote:
>> Hello,
>>
>> I've just begun using HTML::FormFu, and have some suggestions for
>> default_args.  I'd like to be able to apply defaults to any base
>> class, not just the actual blessed name of the object.
>
> Thanks, I've applied this in svn.

Thanks!

> I made a slight change, so that it doesn't require Class::ISA, and
> made handle_defaults() more efficient.
>
> Rather than iterating through the objects ISA, then checking for a
> match in the default_args data, I swapped it round, so we iterate
> through the default_args data, then check for a match using
> $object->isa()

One concern I have with using 'keys %$defaults' is that the defaults
are no longer applied in a predictable order.

If I have

default_args:
  elements:
    _Input: [ key: some_value ]
    Text: [ key: another_value ]

the value for 'key' for Text elements is equally likely to end up as
'some_value' or 'another_value', and can even change between different
runs.

> I've also added support for the old, non-derived behaviour - you just
> need to prefix the type with '+'.
> e.g.:
>    default_args:
>        elements:
>            +Block:
>                auto_id: '%n'
>
> This'll be included in the next cpan release.
>
> Cheers,
> Carl
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>



More information about the HTML-FormFu mailing list