[html-formfu] FormFu::Model subclassing
Moritz Onken
onken at houseofdesign.de
Mon Aug 17 13:16:33 GMT 2009
Am 17.08.2009 um 14:49 schrieb Nick Spacek:
> (I haven't run this code recently) I'm not trying to use
> Model::HashRef, but this is the test that I tried with it. My
> assumption is that $f->{ title } would be set after the form is
> submitted, but dieing there shows it isn't. If I place debug output
> in the update flow in Model::HashRef when it is looping through the
> form elements, it is clear that $element->default is not returning
> any values.
>
> In Controller:
> sub update :Chained('root') Args(0) FormConfig {
> my ( $self, $c ) = @_;
>
> my $form = $c->stash->{ form };
> $form->default_model( 'HashRef' );
>
> if($form->submitted_and_valid) {
> my $f = {title => ''};
> $c->stash->{ form }->model->update( $f );
> }
> }
update and create are the same method in Model::HashRef. Both accept
no arguments but return a hashref. So your example should look
something like this:
> sub update :Chained('root') Args(0) FormConfig {
> my ( $self, $c ) = @_;
>
> my $form = $c->stash->{ form };
> $form->default_model( 'HashRef' );
>
> if($form->submitted_and_valid) {
> my $f = $c->stash->{ form }->model->update;
> }
> }
cheers,
moritz
More information about the HTML-FormFu
mailing list