[html-formfu] Element::Button and its value

Ferruccio Zamuner nonsolosoft at diff.org
Tue Jun 9 10:35:25 GMT 2009


Sorry for my late night post, but I don't understand why:

in my catalyst actions:

...
EDIT:
{
          my $form = $c->stash->{form};
          if ($form->submitted_and_valid) {
              $c->log->debug("form->param_value('cancel')" . Dumper($form->param_value('cancel')));
              last EDIT if ($form->param_value('cancel'));
...
}

output:  HTML::FormFu::Literal=ARRAY(0x2e25e730)
and goto last EDIT

with following params:

.-------------------------------------+--------------------------------------.
| Parameter                           | Value                                |
+-------------------------------------+--------------------------------------+
| first_name                          | Ferruccio                               |
| last_name                           | Zamuner                              |
| picture                             |                                      |
| profile                             | test                                |
'-------------------------------------+--------------------------------------' 

while following test pass:


use strict;
use warnings;

use Test::More tests => 4;

use HTML::FormFu;

my $form = HTML::FormFu->new;

my $submit_cancel = $form->element('Submit')->name('cancel',{value=>'CANCEL'});
my $submit_save = $form->element('Submit')->name('save',{value=>'OK'});

# NOT SUBMITTED
{
    ok( !$form->submitted );
}

# NO INDICATOR, SUBMITTED
{
    $form->process( {
            save => 'OK',
        } );

    ok( $form->submitted );
    ok ($form->param_value('save'), 'save button submitted');
    ok (!($form->param_value('cancel')), 'cancel button not submitted');
}

exit 0;


---

Now I've fixed the web app, using $c->req->param('cancel')

Are 'Submit' buttons to be test in some other way than 
$form->param_value() ?



Bye,             \fer



More information about the HTML-FormFu mailing list