I created a multi-page-form. On page 2 I created a multiplier-field with multicontent. I can fill in the form and the multiplier works fine. (I used the demoforms for both parts- thanks)
I use email and I want all data to be saved to a database. The data of the first page is saved but how can I save the multicontent? What is the syntax and where do I have to use it?
I use email and I want all data to be saved to a database. The data of the first page is saved but how can I save the multicontent? What is the syntax and where do I have to use it?
Hi pokomon,
There are two ways to do this. The simple one is to Json_encode the multiplier data and save the resulting string to a 'text' column in the table. This is fine if you just need an audit trail to record the transactions.
If you want to be able to search and work with the data then you need to use a second table for the multiplier data. You save the main record first, then get the new record ID, add that to each of the multiplier rows and save them as multiple records in the second table. Please see this FAQ for more info.
Bob
There are two ways to do this. The simple one is to Json_encode the multiplier data and save the resulting string to a 'text' column in the table. This is fine if you just need an audit trail to record the transactions.
If you want to be able to search and work with the data then you need to use a second table for the multiplier data. You save the main record first, then get the new record ID, add that to each of the multiplier rows and save them as multiple records in the second table. Please see this FAQ for more info.
Bob
Thanks for the quick answer. I 'll studie the faq later today but I think this is what I was looking for. (I had no clue how to search for it, sorry)
The records in the first table save. [id] is the field I need.
Do I have to add a text field to the multiplier content? What is the syntax to use the [id] and in which field do I have to add that?
Do I have to add a text field to the multiplier content? What is the syntax to use the [id] and in which field do I have to add that?
Hi pokomon ,
You need a Custom Code action that will loop through the multiplier data array and add a new ['id'] entry to each sub-array.
Bob
You need a Custom Code action that will loop through the multiplier data array and add a new ['id'] entry to each sub-array.
<?php
foreach ( $form->data['multi'] as $k => $v ) {
$form->data['multi'][$k]['id'] = $form->data['id'];
}
?>
Replace 'multi' with the name of your multiplier data array.
Bob
I must have changed something somewhere. The debuginfo doesn't show the multi-data anymore. I tried everything but I can't find the problem.
What can be the reason that the debuginfo says:
[shirt] => Array,Array
instead of
[shirt] => Array
(
[1] => Array
(
[style] => bjhk
[size] => kjiu
)
[2] => Array
(
[style] => fkjfgs
[size] => iurt
)
[shirt] => Array,Array
instead of
[shirt] => Array
(
[1] => Array
(
[style] => bjhk
[size] => kjiu
)
[2] => Array
(
[style] => fkjfgs
[size] => iurt
)
When I don't use the handle array event, the content of the array is visible.
Hi Pokomon,
The Handle Arrays action converts an array into a string (and not the reverse). Do you need it here?
Bob
The Handle Arrays action converts an array into a string (and not the reverse). Do you need it here?
Bob
I couldn't get the form working and saving. Multipage, multifield, multisave. I don't understand where and how I get the Id into the new array. Is there a demoform that saves data into two different tables.
Hi pokomon ,
You get the id into the new array using a Custom Code action with code like the example I posted earlier.
Bob
You get the id into the new array using a Custom Code action with code like the example I posted earlier.
Bob
Hi pokomon,
What code did you use exactly?
What do you see in the Debugger output?
Bob
What code did you use exactly?
What do you see in the Debugger output?
Bob
I bumped into different problems so I just started from scratch.
The first problem: multipage
On the demomultipage I put some fields on every page and save it to a database. This doesn't update but create a new record on every page (save).
The second problem: multifield - connection to the id or cf_id
I added a multifield in a container multiplier/container multiplier content on the second page. I followed the steps for the container multiplier.
I also have a hidden field cf_id on every page
Debug info after page 1
Array
(
[option] => com_chronoforms5
[chronoform] => demo-multipageTest
[event] => page2
[text5] => fgg
[cf_id] => 43
[id] =>
[button6] => Volgende1
)
Debug info after page 2
Array
(
[option] => com_chronoforms5
[chronoform] => demo-multipageTest
[event] => page3
[text5] => fgg
[cf_id] =>
[id] =>
[button6] => Volgende1
[dropdown7] => 0
[multi] => Array
(
[1] => qfdqfar
)
[button8] => Volgende2
)
I don't understand where I need to put the custom code. In the designer tab (on the first page or second page) or in the setup page event of the second page? This is the code I used. I changed id in cf_id. This is the id_field in the first debuginfo-array.
<?php
foreach ( $form->data['multi'] as $k => $v ) {
$form->data['multi'][$k]['id'] = $form->data['cf_id'];
}
?>
The first problem: multipage
On the demomultipage I put some fields on every page and save it to a database. This doesn't update but create a new record on every page (save).
The second problem: multifield - connection to the id or cf_id
I added a multifield in a container multiplier/container multiplier content on the second page. I followed the steps for the container multiplier.
I also have a hidden field cf_id on every page
Debug info after page 1
Array
(
[option] => com_chronoforms5
[chronoform] => demo-multipageTest
[event] => page2
[text5] => fgg
[cf_id] => 43
[id] =>
[button6] => Volgende1
)
Debug info after page 2
Array
(
[option] => com_chronoforms5
[chronoform] => demo-multipageTest
[event] => page3
[text5] => fgg
[cf_id] =>
[id] =>
[button6] => Volgende1
[dropdown7] => 0
[multi] => Array
(
[1] => qfdqfar
)
[button8] => Volgende2
)
I don't understand where I need to put the custom code. In the designer tab (on the first page or second page) or in the setup page event of the second page? This is the code I used. I changed id in cf_id. This is the id_field in the first debuginfo-array.
<?php
foreach ( $form->data['multi'] as $k => $v ) {
$form->data['multi'][$k]['id'] = $form->data['cf_id'];
}
?>
This topic is locked and no more replies can be posted.