Hello,
I am trying to test Handle arrays action and understand how the system works.
It doesn't work as I imagined. There is something wrong in my actions.
Here is my use case:
In Design tab:
1- creation of multifield of 2 fields.
Field name= text[0], Filed ID=text0.
Field name= text[1], Filed ID=text1.
2- creation of Submit button
MySQL table:
1- creation of table from Chronoform form manager page.
2- modify the fields proposed by form manager: the 2 lines of text[0], and text[1] ---> 1 line with text (with the same type VARCHAR(255) as text[0], and text[1])
In Setup tab:
1. activate HTML form in On Load section
2. add Handle arrays with no specific value. I let it as it is.
3. add DB Save action with model ID enable (with the Model ID name "data").
4. add Debugger before DB Save, and after DB Save.
Execution of this use case, Enter s1 and s2 in the 2 fields, and submit the form. Here are the results:
Debugger Before DB Save:
Debugger after DB Save:
The colum text in MySql table is empty as the debugger showed. Nothing is insert into table. Could someone give me a help for this and explain me what are wrong? I am interested by the documentation on Chronoform V5, if exist.
Thanks
Bertrand
I am trying to test Handle arrays action and understand how the system works.
It doesn't work as I imagined. There is something wrong in my actions.
Here is my use case:
In Design tab:
1- creation of multifield of 2 fields.
Field name= text[0], Filed ID=text0.
Field name= text[1], Filed ID=text1.
2- creation of Submit button
MySQL table:
1- creation of table from Chronoform form manager page.
2- modify the fields proposed by form manager: the 2 lines of text[0], and text[1] ---> 1 line with text (with the same type VARCHAR(255) as text[0], and text[1])
In Setup tab:
1. activate HTML form in On Load section
2. add Handle arrays with no specific value. I let it as it is.
3. add DB Save action with model ID enable (with the Model ID name "data").
4. add Debugger before DB Save, and after DB Save.
Execution of this use case, Enter s1 and s2 in the 2 fields, and submit the form. Here are the results:
Debugger Before DB Save:
Data Array
Array
(
[chronoform] => Array
[event] => submit
[text] => Array
(
[0] => s1
[1] => s2
)
[button2] => Submit
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
)
Debugger after DB Save:
Data Array
Array
(
[chronoform] => Array
[event] => submit
[text] => s1,s2
[button2] => Submit
[data] => Array
(
[id] => 1
)
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
[2] => Array
(
[DB Save] => Array
(
[Queries] => Array
(
[0] => INSERT INTO `kxeq8_chronoengine_chronoforms_datatable_Array` (`user_id`, `uniq_id`, `created`) values ('87', '1c6196c41cd1973c2649bd215bb43f8d182a486e', '2015-11-10 07:22:19');
)
)
)
)
The colum text in MySql table is empty as the debugger showed. Nothing is insert into table. Could someone give me a help for this and explain me what are wrong? I am interested by the documentation on Chronoform V5, if exist.
Thanks
Bertrand
Hi Betrand,
I don't think that you can use text[0] as a MySQL column name. You could use text_0, or just text - that depends on what you are trying to do here???
The Handle Arrays needs to be before the DB Save is you want to save the combined value to the text column. You can see that it has run somewhere between your two screenshots.
Bob
I don't think that you can use text[0] as a MySQL column name. You could use text_0, or just text - that depends on what you are trying to do here???
The Handle Arrays needs to be before the DB Save is you want to save the combined value to the text column. You can see that it has run somewhere between your two screenshots.
Bob
Hello Bob,
Thanks Bob,
I do know that MySQL does not support array, and I can not use text[] in MySQL table.
This is why in MySQL table "text" is a string when creating a table.
In Design Tab:
Field name= text[0], Filed ID=text0.
Field name= text[1], Filed ID=text1.
In MySQL table, I only have "text" as a colum and as a string. The "text" type is VARCHAR(255).
Before Handle Arrays action, I got:
[text] => Array
(
[0] => s1
[1] => s2
)
After Handle Array action, I got: [text] => s1,s2
Handle action is in Submit action, and before DB Save action.
My question is why I did not get anything written in MySQL table? What is wrong with this and what do I need to do?
This is what I understood from this FAQ:
https://www.chronoengine.com/faqs/63-cfv4/cfv4-working-with-form-data/3222-how-can-i-get-useful-data-from-select-drop-downs-checkboxes-and-radio-buttons.html
Bertrand
Thanks Bob,
I do know that MySQL does not support array, and I can not use text[] in MySQL table.
This is why in MySQL table "text" is a string when creating a table.
In Design Tab:
Field name= text[0], Filed ID=text0.
Field name= text[1], Filed ID=text1.
In MySQL table, I only have "text" as a colum and as a string. The "text" type is VARCHAR(255).
Before Handle Arrays action, I got:
[text] => Array
(
[0] => s1
[1] => s2
)
After Handle Array action, I got: [text] => s1,s2
Handle action is in Submit action, and before DB Save action.
My question is why I did not get anything written in MySQL table? What is wrong with this and what do I need to do?
This is what I understood from this FAQ:
https://www.chronoengine.com/faqs/63-cfv4/cfv4-working-with-form-data/3222-how-can-i-get-useful-data-from-select-drop-downs-checkboxes-and-radio-buttons.html
Bertrand
HI Bertrand,
Please try clicking the Delete Cache icon in the ChronoForms toolbar to update the saved table records, hopefully it will then recognise the text column in the DB Save.
Bob
Please try clicking the Delete Cache icon in the ChronoForms toolbar to update the saved table records, hopefully it will then recognise the text column in the DB Save.
Bob
Bob,
Clear cache done. It works fine.
Is there something to have the reverse of Handle Array action?
I mean, when I get data from DB read, the text is a string.
How to get this string in a array, as "text" is defined as an array in my initial chronoform.
I tried to put a custom code action with php code (after the DB read) to explode the "text" string into array, and loop up the previous values stored in my record into my form.
I did not success to upload the data in my fields. I have a lot to learn here....😟
Here is the custom code, just after the DB read action, I tried to do
Bob, I think that it is not the first question I ask my self.
What is usual operation to do when user wants to read the data after the Handle Array action?
Bertrand
Clear cache done. It works fine.
Is there something to have the reverse of Handle Array action?
I mean, when I get data from DB read, the text is a string.
How to get this string in a array, as "text" is defined as an array in my initial chronoform.
I tried to put a custom code action with php code (after the DB read) to explode the "text" string into array, and loop up the previous values stored in my record into my form.
I did not success to upload the data in my fields. I have a lot to learn here....😟
Here is the custom code, just after the DB read action, I tried to do
<?php
$mytext=$form->data['text'];
$text = array();
$text= explode(",",$mytext);
var_dump($text);
?>
Bob, I think that it is not the first question I ask my self.
What is usual operation to do when user wants to read the data after the Handle Array action?
Bertrand
This topic is locked and no more replies can be posted.