[html-formfu] Can't get the basic Model::DBIC belongs_to/has_many Repeatable example to work

Dan Dascalescu ddascalescu+formfu at gmail.com
Fri Jul 10 08:58:06 GMT 2009


I'm trying to follow along with the HTML::FormFu::Model::DBIC example
for editing a Book and its Review, but I want to _create_ the
book/review pair. However, only the Book's title gets created, and the
Review is not.

The schema is pasted from the example
(http://search.cpan.org/~cfranks/HTML-FormFu-Model-DBIC-0.05002/lib/HTML/FormFu/Model/DBIC.pm#has_many_and_many_to_many_relationships)

Here are the relevant files:

package Library::Controller::Root;

[...]

sub add :Local :FormConfig {
    my ( $self, $c ) = @_;

    my $form = $c->stash->{form};

    if ( $form->submitted_and_valid ) {
        my $book = $c->model('DB::Book')->new_result({});

        # update dbic row with submitted values from form
        $form->model->update( $book );

        $c->response->redirect( $c->uri_for('list') );
        return;
    }
    elsif ( !$form->submitted ) {

    }

    return;
}



add.yml (pasted from the example and added a Submit button):

elements:
  - type: Text
    name: title

  - type: Hidden
    name: review_count

  - type: Repeatable
    nested_name: review
    counter_name: review_count
    elements:
      - type: Hidden
        name: book

      - type: Textarea
        name: review_text

  - name: submit
    type: Submit


I put up a barebones app to test at http://privatepaste.com/download/891nbKz39K.

After adding a book and its review via the form, the book is added to
the database, but the review is not. There are no errors and nothing
unusual in the server log.

What am I doing wrong?



More information about the HTML-FormFu mailing list