[html-formfu] Repeatable displays every row in table (bug?)
Greg Coates
greg at coatesoft.com
Thu May 7 21:13:10 GMT 2009
OK. Let me try again, then.
I have a form that is used to display invoices from a table called
'invoices'. It contains a Repeatable that is used to display the
individual lines for those invoices. These lines come from a table
called 'invoice_items'.
When the form is used on an existing record, all is well. However, when
I use the form to create a new record, I have a problem. Instead of the
Repeatable being blank, every row from the 'invoice_items' table is
displayed.
Greg
Mario Minati wrote:
> Your problem description seems to be missing a few words, actually I don't
> understand your problem.
>
> Greets,
>
> Mario Minati
>
> Am Mittwoch 06 Mai 2009 01:05:18 schrieb Greg Coates:
>> I have a form that contains a repeatable block that I'm using with
>> Catalyst. Everything works fine for existing master records. However,
>> when I use the form to create a new record, every record in the table
>> for the has many relationship. This is less than optimal.
>>
>> Here's the repeatable block from the form definition:
>>
>> - type: Repeatable
>> name: invoice_lines
>> nested_name: invoice_items
>> counter_name: line_cnt
>> auto_id: "%n"
>> attributes:
>> class: data_row invoice_item
>> 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 numeric
>> elements:
>> - type: Text
>> name: ivi_unit_price
>> size: 8
>> - type: Block
>> attributes:
>> class: ivi_quantity numeric
>> elements:
>> - type: Text
>> name: ivi_quantity
>> size: 5
>> - type: Block
>> attributes:
>> class: ivi_total_price numeric
>> 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
>> empty_first_label: <no inventory item>
>> 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
>> empty_first_label: <no tax>
>> model_config:
>> resultset: Taxes
>> id_column: tax_id
>> label_column: tax_desc
>> - type: Block
>> attributes:
>> class: ivi_memo
>> elements:
>> - type: Text
>> name: ivi_memo
>> size: 100
>>
>>
>> And here's the relevant part of my Catalyst controller:
>>
>> sub edit :Local :FormConfig('invoices/edit_invoice.yml') {
>> my ($self, $c, $ivc_id) = @_;
>>
>> if ($c->request->param('cancel')) {
>> $c->response->redirect($c->uri_for("/invoices"));
>> $c->detach();
>> }
>>
>> my $invoice = ($ivc_id) ? $c->model('DB::Invoices')->find($ivc_id)
>>
>> : $c->model('DB::Invoices')->new_result({});
>>
>> my $form = $c->stash->{form};
>> if ($form->submitted_and_valid()) {
>> $form->process();
>> $form->model->update($invoice);
>>
>> if (! $c->request->param('draft')) {
>> # Save to accounts
>> }
>>
>> $c->response->redirect($c->uri_for("/invoices"));
>> $c->detach();
>> }
>> }
>>
>> Any ideas, folks?
>>
>> Thanks,
>> Greg Coates
>> Coatesoft
>>
>> _______________________________________________
>> HTML-FormFu mailing list
>> HTML-FormFu at lists.scsys.co.uk
>> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>
>
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
More information about the HTML-FormFu
mailing list