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

Zbigniew Lukasiak zzbbyy at gmail.com
Sun Feb 24 14:55:01 GMT 2008


On Wed, Feb 20, 2008 at 12:00 PM, Carl Franks <fireartist at gmail.com> wrote:
> 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)

Hmm -  is there any theory behind that?  I cannot see any reason why
you should not be able to change some form value after it's been
submitted.  What am I missing?

-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/



More information about the HTML-FormFu mailing list