Am Donnerstag 29 März 2007 05:43 schrieb Daisuke Maki:
> Hi,
>
> I have a form that should have today's date in it unless otherwise
> specified. I kind of hacked around this by saying:
>
>     my $dt = DateTime->today(time_zone => 'local');
>     foreach my $field qw(year month day) {
>         my $element = $form->get_field(name => $field, type => 'text');
>         next unless $element;
>         $element->attributes->{value} ||= $dt->$field;
>     }
>
> Is there are preferred/recommended way to do this?

I think a good place to do it could be a deflator, this way you don't need 
extra code for form creation.

I think there is an example DataTime deflator. Maybe it needs no be extended 
to set the current date if the given value is undef. But I'm not sure on that 
and I'm in a hurry so I can look into.

Greets,
Mario

_______________________________________________
Html-widget mailing list
Html-widget@lists.rawmode.org
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget

Reply via email to