[html-formfu] Select elements inside Repeatables

Greg Coates greg at coatesoft.com
Wed Apr 15 18:03:25 GMT 2009


I'm using a Repeatable element that contains several Select elements in
a form displayed by a Catalyst controller.  The problem is, the Select
elements aren't being populated.  Before I put them into the Repeatable
element, they worked fine.  Does anybody have a fix for this?

Here's my controller code:

sub edit :Local :FormConfig('invoices/edit_invoice.yml') {
   my ($self, $c, $ivc_id) = @_;

   my $form = $c->stash->{form};
   my $invoice = ($ivc_id) ? $c->model('DB::Invoices')->find($ivc_id)
                           : $c->model('DB::Invoices')->new_result({});

   if ($c->request->param('cancel')) {
     $c->response->redirect($c->uri_for("/invoices"));
     $c->detach();
   }

   if ($form->submitted_and_valid()) {
     $form->model->update($invoice);
     $c->response->redirect($c->uri_for("/invoices"));
     $c->detach();
   } else {
     $form->model->default_values($invoice);
   }

   $c->stash->{ivc_id} = $ivc_id;
   $c->stash->{template} = 'invoices/invoice_edit.tt';
   $c->stash->{stylesheet} = 'invoices/invoice_edit.css';
}


And here's the YML for the form:
---
load_config_file: setup.yml
auto_fieldset:
   attributes:
     class: field_group
elements:
   - type: Block
     elements:
       - type: "+Coatesoft::FormFu::Element::DataLabel"
         label: Invoice Number
         name: ivc_id
   - type: Block
     elements:
       - type: Select
         name: ivc_vendor
         label: Vendor
         constraints:
           - type: Integer
           - type: Required
         model_config:
           resultset: Contacts
           id_column: ctc_id
           label_column: ctc_common_name
   - type: Block
     elements:
       - type: Text
         name: ivc_invoice_number
         label: Vendor's Invoice Number
         size: 20
         constraints:
           - type: Printable
   - type: Block
     elements:
       - type: Text
         name: ivc_invoice_date
         label: Invoice Date
         size: 15
         constraints:
           - type: Required
   - type: Fieldset
   - type: Repeatable
     name: invoice_lines
     nested_name: invoice_items
     attributes:
       class: data_row
     elements:
       - type: Hidden
         name: ivi_id
       - type: Block
         attributes:
           class: ivi_desc
         elements:
           - type: Text
             name: ivi_desc
             size: 75
       - type: Block
         attributes:
           class: ivi_unit_price
         elements:
             - type: Text
               name: ivi_unit_price
               size: 8
       - type: Block
         attributes:
           class: ivi_unit_price
         elements:
           - type: Text
             name: ivi_quantity
             size: 5
       - type: Block
         attributes:
           class: ivi_total_price
         elements:
           - type: "+Coatesoft::FormFu::Element::DataLabel"
             name: ivi_total_price
       - type: Block
         attributes:
           class: ivi_account
         elements:
           - type: Select
             name: ivi_account
             model_config:
               resultset: Accounts
               id_column: acc_id
               label_column: acc_title
       - type: Block
         attributes:
           class: ivi_item
         elements:
           - type: Select
             name: ivi_item
             empty_first: 1
             model_config:
             model_config:
               resultset: Items
               id_column: itm_id
               label_column: itm_description
       - type: Block
         attributes:
           class: ivi_tax_type
         elements:
           - type: Select
             name: ivi_tax_type
             empty_first: 1
             model_config:
               resultset: Taxes
               id_column: tax_id
               label_column: tax_desc
   - type: Fieldset
     attributes:
       class: buttons
   - type: Submit
     name: submit
     value: Save Invoice
   - type: Submit
     name: cancel
     value: Cancel
   - type: Hidden
     name: count

filter:
   - TrimEdges
   - HTMLEscape



Thanks,
Greg Coates
Coatesoft




More information about the HTML-FormFu mailing list