[html-formfu] Use default_values() and update() methods of H::F::M::DBIC

Octavian Rasnita orasnita at gmail.com
Fri Nov 7 12:52:55 GMT 2008


Hello,

I try to use H::F::M::DBIC (because I want to update a related table easier), but I can't even use default_values() and update() methods.

$form->default_values doesn't do anything, while $form->update gives the error "Can't locate object method "update" via package "HTML::FormFu".

$form->model->default_values and $form->model->update work fine though.

Am I doing something wrong, or H::F::M::DBIC is not working yet?
Please tell me if there is a sample program that uses H::F::M::DBIC methods.

Thanks.

I tried:

package MyApp::Controller::Root;

use strict;
use warnings;
use parent 'Catalyst::Controller::HTML::FormFu';
__PACKAGE__->config->{namespace} = '';

sub index :Path :Args(0) : FormConfig {
  my ( $self, $c ) = @_;

  my $test = $c->model("DB::Test")->find(1);
  my $form = $c->stash->{form};

  if ($form->submitted_and_valid) {
    $form->update($test);
  }
  else {
    $form->default_values($test);
  }
}

sub end : ActionClass('RenderView') {}
1;

In MyApp.pm:

__PACKAGE__->config(
  'Controller::HTML::FormFu' => {
    model_stash => {
      schema => 'DB',
    },
  },
);

In root/forms/index.conf:

<model_config>
resultset Test
</model_config>

<element>
type Text
name name
label Nume:
constraint Required
filter TrimEdges
</element>

<element>
type Textarea
name detail
label Detalii:
</element>

<element>
type Hidden
name submit
value 1
</element>

<element>
type Submit
value OK
</element>
indicator submit



Octavian




More information about the HTML-FormFu mailing list