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?

_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to