[html-formfu] default values and submitted

Andreas Marienborg omega at palle.net
Tue Jul 22 16:27:26 BST 2008


Hey

Stumbled upon something strange today.

My pattern (pseudo) for most formfu things is this:


sub create : bla FormEtc{

my $obj : Stashed = $c->model->new({ parent => $c->req- 
 >param('parent') });

$c->forward('doit');

}

sub edit : blah FormEtc {

	my $obj : Stashed = $c->model->find($id);

$c->forward('doit');

}

sub doit : blah {

     if ($form->submitted_and_valid) {
	$form->model()->update($obj);
    }
}


now the problem is that for create where parent is set, results in  
submitted_and_valid triggering, can I prevent that somehow? if I set  
constraints on the form elements, they stop it, but this results in  
red boxes, which isn't really true, since its just showing the form  
for the first time.

Or should I manually check for $c->req->method eq 'POST'?

- andreas



More information about the HTML-FormFu mailing list