[html-formfu] Date element does not render default values

Carl Franks fireartist at gmail.com
Tue Apr 15 09:41:22 BST 2008


On 04/04/2008, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:
> I am attaching slightly modified
>  HTML-FormFu-Model-DBIC/t/default_values/basic.t - it shows that even
>  though:
>
>  # column is inflated
>     my $date = $fs->get_field('date_col')->default;
>     isa_ok( $date, 'DateTime' );
>     is( $date->year,  '2009' );
>
>  It still does not render the year as selected:
>
>     like( "$form", qr{<option value="2007"
>  selected="selected">2007</option>}, 'Year rendered properly' );  #this
>  fails

This is the old problem of some element types not liking any changes
being made after `$form->process()` is called.

I think it's reasonable, though, for default() to just Do The Right
Thing, and not require the user to call `$form->process` again - so
I've fixed it by overriding value() (which is aliased to default) in
Date.pm, so that it automatically calls the Select menu's default()
methods, if process() has already been called.

There's now a test for this in HTML-FormFu/t/elements/date_default.t

Carl



More information about the HTML-FormFu mailing list