Skip Menu |

This queue is for tickets about the HTML-FormFu CPAN distribution.

Report information
The Basics
Id: 39871
Status: resolved
Priority: 0/
Queue: HTML-FormFu

People
Owner: Nobody in particular
Requestors: rod.taylor [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.03005
Fixed in: (no value)



Chekbox defaults seem to require both $field->value() and $field->default() to be set. LIKE THIS: my $fk = $form->get_field($formKey); $fk->default($measurementValue); $fk->value($measurementValue); The offending code appears to be in HTML::FormFu::Element::Checkbox at line 57. my $default = $self->default; my $original = $self->value; . . . 57| elsif ( defined $default && defined $original && $default eq $original ) { $render->{attributes}{checked} = 'checked'; } Here you can see if looks for both $default and $original to be defined even when the form has not been submitted. It should probably be something like (defined $default || defined $original).
Hi, Can you check the documented behaviour [1], and then describe what you want to happen, as I'm not sure what you're reporting as being wrong. [1] http://search.cpan.org/~cfranks/HTML-FormFu-0.03005/lib/HTML/FormFu/Element/_Field.pm#value Cheers, Carl
From: rod.taylor [...] gmail.com
On Fri Oct 31 15:18:40 2008, CFRANKS wrote: Show quoted text
> Hi, > > Can you check the documented behaviour [1], and then describe what you > want to happen, as I'm not sure what you're reporting as being wrong. > > [1] > http://search.cpan.org/~cfranks/HTML-FormFu- > 0.03005/lib/HTML/FormFu/Element/_Field.pm#value > > Cheers, > Carl
Technically I suppose it works as documented. To get a checkbox checked I need to do this: $field->value($value); $field->default($value); Both $value and $default were undef since that is how FormFu initializes their state. For a single checkbox, I think this is overkill and the checkbox should be checked if $value has a value regardless of what the default might be.
CheckBox has been changed, so value() now defaults to 1. This means default(1) will now do what you expect, and you'll only need to set value() if you intend using a different value, such as 'on' or 'checked'.