Create Header & Detail form (like sales order) and save them in separate tables

mauropiro 19 Oct, 2018
My dear,

I need help with chronoform6 to save sales order (header and detail).

I developed a part using multipage and I was able to write the header, but I can not iterate the data of the items in the detail database.

This is a simple template I did:

Header (form ONE)
Fields:
date (calendar)
order_number (text field)
customer (drop down, from read_data)
payment_type (radio: cash or installment)

Next button (call page2 action) > save_data (date, order_number, customer, payment_type)

Detail (form TWO)
Fields:
order_number (session from previous page)
item (drop down from read_data)
unit_value (text field)
qty (text field)

save item button > I can not iterate item data (more than one item).

I tried to use loop event but I could not save all the items in the detail table.

I think I am banging my head against the wall.

Thank you in advance,

Mauro
healyhatman 23 Oct, 2018
Why are you trying to iterate item data? Do you mean that you have a repeater field on page 2?
mauropiro 23 Oct, 2018
Dear Healyhatman

I tried to use repeater field but I could not iterate the data in the database, it only records the last data, the previous ones are not recorded.

For this reason it would be interesting for us to have more DEMOS available in the extensions CC & CF. The DEMOS facilitate the understanding of the logic necessary for the correct operation.

If you can guide me how to use the repeater field, I will be very grateful.

Thank you for all.

Mauro
healyhatman 23 Oct, 2018
What have you named the fields in your repeater?
mauropiro 23 Oct, 2018
Here are the steps I did:

1. I did as explained on page 40 of the chronoforms 6 manual, starting in the topic Dynamic Multiplier
Create Header & Detail form (like sales order) and save them in separate tables image 1

2. I wrote the repeater area in the data provider field of save_data component, but as it was not writing to the database, then I inserted the fields manually into 'Data override on Insert'. I think it was here that I went wrong
Create Header & Detail form (like sales order) and save them in separate tables image 2
3. I've added 2 items for order number 505
Create Header & Detail form (like sales order) and save them in separate tables image 3

4. And in the database we have only the last item inserted.
Create Header & Detail form (like sales order) and save them in separate tables image 4

Thank you for your help

Mauro
healyhatman 23 Oct, 2018
It's only saving one copy because you haven't told it to give each field a unique name. Each repeater row you add all the fields are named the same so only the last copy of data actually gets sent.

Rename the fields to order[{var:area_repeater#.key}][field_name] and use {data: order} as the data source for your loop event to save your data.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger