[Html-widget] formfu - What's the best way to add dynamic
defaults?
Mario Minati
mario.minati at googlemail.com
Thu Mar 29 08:46:39 GMT 2007
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
More information about the Html-widget
mailing list