[Html-widget] formfu - What's the best way to add dynamic defaults?

Daisuke Maki daisuke at endeworks.jp
Thu Mar 29 04:43:35 GMT 2007


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?

--d




More information about the Html-widget mailing list