[Catalyst] problem with FormBuilder + TT2

Karl.Moens at marsh.com Karl.Moens at marsh.com
Tue Sep 19 12:13:23 CEST 2006

John Napiorkowski wrote:
> (snip)
> Hey, question for you; are you using Formbuilder with
> a database?  If so what are you doing to manage
> getting stuff between formbuild and your datbase of
> choice?  I'm using DBIx and just doing braindead stuff
> like writing a bunch of $c->form->field(name=>,
> value=>) but I figure there's a better way.  I just
> can't seem to get DBIx::Class::FormTools to do what I
> think it can do for me.  Maybe I just need more work
> on it.

I'm using Catalyst::Plugin::FormBuilder and in order to transfer data back
and forth between the forms and the database (accessed with DBIx::Class) I
do something like:

1. Make sure that your form-fields have the same names as your columns
2. Give your sub-routines to which Catalyst dispatches your URL's the ":
Form" attribute.
3a. To add a record:
   <code>my ( $self, $c ) = @_;
         if ($c->form->submitted && $c->form->validate) {
            my $record=$c->model('Your::table')->create(scalar
3b. To edit a record:
   <code>my ( $self, $c, $key ) = @_;
    my $record=$c->model('Your::table')->find($key);
    if ($c->form->submitted && $c->form->validate) {
        $record->update(scalar $c->form->field());
    else {
        map {$c->form->field('name' => $_, 'value' => $record->$_)}

Easy as pie!

aka CountZero at Perlmonks

This message and any attachments are confidential. If you have received
this message in error please delete it from your system. If you require any
assistance please notify the sender. Thank You.

More information about the Catalyst mailing list