Thanks for your help, Moritz. I can still only save the first record in
any many-to-many relationship, though.

I have created a little test project to try out your suggestions. The
only part I do not understand is how to ensure the schema is in the
form's stash. I'm afraid I don't understand how to use it at all. If I
used the following line to set up the model:

$ script/omtsweb_create.pl model DB DBIC::Schema OMTSWeb::Schema
create=static dbi:SQLite:omtsweb.db

then my ModelName is 'DB'? Am I supposed to change the DBIC::Schema to
DBIx::Schema?

Also, would you be able to provide me with an example of the MyApp.pm
file? (In my case, I think the file I need is OMTSWeb/lib/OMTSWeb.pm)  I
cannot see how to add the necessray lines to that file at all. The
closest example I can come up with is:

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

I don't see anywhere to add this:

<Controller::HTML::FormFu>
<model_stash>
 schema DB
</model_stash>
</Controller::HTML::FormFu>

Thank you again. I do appreciate the help and apologize for being a slow
learner.

Shawn Moughtin
Thunder Bay, Canada


Moritz Onken wrote:



sub formfu_edit :Local :FormConfig('prior/formfu_create.yml') {
      my ($self, $c, $id) = @_;

      # Get the specified book
      my $book = $c->model('DB::Prior')->find($id);

      # Make sure we were able to get a book
      unless ($book) {
$c->flash->{error_msg} = "Invalid prior record -- Cannot edit";
          $c->response->redirect($c->uri_for('listprior'));
          $c->detach;
      }

      # Get the form that the :FormConfig attribute saved in the stash
      my $form = $c->stash->{form};

      if ($form->submitted_and_valid) {

          $form->save_to_model($book);


This should ne $form->model->update($book);
save_to_model is deprecated.


  <Controller::HTML::FormFu>
      <model_stash>
          schema = ModelName
      <model_stash>
  </Controller::HTML::FormFu>

There are some typos in that part
correct (fixed in svn):

<Controller::HTML::FormFu>
<model_stash>
  schema ModelName
</model_stash>
</Controller::HTML::FormFu>


"ModelName" is the name you use when you call $c->model('ModelName') to access the model.

moritz

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




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

Reply via email to