I have created a repeatable block and it populates correctly, but it
will not save any changes I make to those records. It will save the
previous fields in the form, though. I am using Catalyst and Formfu.

Here's my calling subroutine. I've taken it from an example online and
added the repeatable section to it.

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);

           $c->flash->{status_msg} = 'Record ammended';

           $c->response->redirect($c->uri_for('listprior'));
           $c->detach;

       } else {

           $form->defaults_from_model($book);
       }

       # Set the template
       $c->stash->{template} = 'prior_approval/formfu_create.tt2';
}


My formfu_create.yml file is:

indicator: submit

elements:
  - type: Text
    name: client_number
    label: Status Number
    attributes:
      title: Enter the Client's Status Number
    constraints:
      - type: Integer
        message: "Required. Digits only, please."
      - type: Length
        min: 9
        max: 10
        message: Length must be between 9 and 10 characters

  - type: Text
    name: client_first_name
    label: Client First Name
    constraints:
      - type: Length
        min: 2
        max: 50
        message: Length must be between 2 and 50 characters

  - type: Text
    name: client_last_name
    label: Client Last Name
    constraints:
      - type: Length
        min: 2
        max: 50
        message: Length must be between 2 and 50 characters

  - type: Text
    name: client_dob
    label: Date of Birth
    attributes:
      title: Format is yyyy/MM/dd

  - type: Repeatable
    auto_id: "%n"
    nested_name: appointments
    model_config:
      DBIC:
        new_empty_row: appointment_date
        delete_if_true: deletion_marker

    element:
      - type: Hidden
        name: appointment_id

      - type: Text
        name: appointment_date
        label: Appointment Date

      - type: Checkbox
        name: deletion_marker

  - type: Submit
    name: submit
    value: Submit


I have been over the documentation and the only two things I think it
may be are that I don't actually specify the appointments model in a
save statement, but it seems like Catalyst takes care of that. I also
don't understand this statement in the documentation for
HTML::FormFu::Model::DBIC

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


Is my modelname in this case DB::Prior and does this chunk of code go
into my config file in the very root of my application? in MyApp.conf (I
use Apache style)

Thank you for your help in this.


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

Reply via email to