[html-formfu] Date field and rendering a hidden field

Carl Franks fireartist at gmail.com
Wed Feb 20 11:00:43 GMT 2008


On 15/02/2008, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:
> This looks quite weird.  When I render my form the hidden field does
> not get it's value.
>
> Here is the code:
>
> use strict;
> use warnings;
>
> use HTML::FormFu;
>
> my $form = HTML::FormFu->new;
> $form->load_config_file( 'e.yml' );
> $form->process( { first_instance_date_year => 2008 } );
> my $ind = $form->get_all_element( { name => 'event_indicator' } );
> $ind->default( 1 );
> warn $ind->value;
> warn $ind->render;
> warn $ind->value;
>
> __OUTPUT__
> 1 at form.t line 11.
> <input name="event_indicator" type="hidden" value="" /> at form.t line 12.
> 1 at form.t line 13.
>
> So it looks that the hidden field does have the value - but it is not
> printed out when rendering. And it happens only after processing the
> Date element.

This is the expected behaviour.

default() is only used if the form hasn't been submitted.

In this case, you need to set $hidden->retain_default(1)

Carl



More information about the HTML-FormFu mailing list