Hello there,
following this faqhttps://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 here I created the following script in a custom element
but when I place {appliances_names} the data is not showing.
any idea?
following this faqhttps://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 here I created the following script in a custom element
<?php
$appliances_array = array(
S_Refrigerator => 'Small Refrigerator (<100lt)',
L_Refrigerator => 'Large Refrigerator (>100lt)',
TV => 'TV (LCD)',
Radio => 'Stereo (DVD, Radio, CD, etc)',
Satellite => 'Satellite',
Fan => 'Air fan',
PC => 'PC',
Few_lights => 'Few Lights (<5)',
Many_lights => 'Many Lights'
);
$appliances_names = array();
foreach ( $form->data['appliances'] as $v ) {
$appliances_names[] = $appliances_array[$v];
}
$form->data['appliances_names'] = implode(', ', $appliances_names);
?>
but when I place {appliances_names} the data is not showing.
any idea?
Hello faitas,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
My form data isn't saving to the database correctly
How do I save form data to a database table?
How to load record data from a database table into your form
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
My form data isn't saving to the database correctly
How do I save form data to a database table?
How to load record data from a database table into your form
P.S: I'm just an automated service😉
Hi faitas,
You need quotes round both parts of the array entries. So use
Bob
You need quotes round both parts of the array entries. So use
'S_Refrigerator' => 'Small Refrigerator (<100lt)',
with quotes round S_Refrigerator and the same for all the others.
Bob
Tryied that as well, it is not working!
<?php
$appliances_array = array(
'S_Refrigerator' => 'Small Refrigerator (<100lt)',
'L_Refrigerator' => 'Large Refrigerator (>100lt)',
'TV' => 'TV (LCD)',
'Radio' => 'Stereo (DVD, Radio, CD, etc)',
'Satellite' => 'Satellite',
'Fan' => 'Air fan',
'PC' => 'PC',
'Few_lights' => 'Few Lights (<5)',
'Many_lights' => 'Many Lights'
);
$appliances_names = array();
foreach ( $form->data['appliances'] as $v ) {
$appliances_names[] = $appliances_array[$v];
}
$form->data['appliances_names'] = implode(', ', $appliances_names);
?>
i faitas,
The code looks OK - what do you see when you add a Debugger action after that?
Bob
The code looks OK - what do you see when you add a Debugger action after that?
Bob
This is what I see:
Array
(
[option] => com_chronoforms
[chronoform] => off-grid_system_SHOW
[sunray] => 14
[language] => en-GB
[Itemid] =>
[lang] => en
[cf_id] => 14
[cf_uid] => 05db5ed7212a020c8a3b922b83a648ff
[cf_created] => 2014-07-07 07:35:03
[cf_ipaddress] => 62.103.76.60
[cf_user_id] => 2901
[firstname] => testing
[Last_Name] => maniak
[email] => cfaitatzoglou@gmail.com
[phone] => 454454661
[latitude] => 39.147103
[longitude] => 29.827881
[location] => Kütahya Province, Turkey
[radio_type] => medium
[area] => 45
[period] => summer
[use_days] => weekends
[appliances] => L_Refrigerator,Fan,PC
[terms] => 1
[vcode] => da0039ea66b9988b4eb2e34ef3f51d33
[vstatus] => 1
[notes] =>
)
Validation Errors:
Array
(
)
Hi faitas,
It looks as though you have a Handle Arrays action before the Custom Code action, Please try moving the Custom Code action so that is runs before the Handle Arrays.
Bob
It looks as though you have a Handle Arrays action before the Custom Code action, Please try moving the Custom Code action so that is runs before the Handle Arrays.
Bob
my events are as in the attached picture. I do not have any handle arrays action ... should I?
[attachment=0]Capture.JPG[/attachment]
[attachment=0]Capture.JPG[/attachment]
HI faitas,
I'm sorry but I have no idea what you are trying to do here :-(
If there is nothing in the On Submit event where are you trying to show these values?
Bob
I'm sorry but I have no idea what you are trying to do here :-(
If there is nothing in the On Submit event where are you trying to show these values?
Bob
Hi faitas,
In that case the saved data
Bob
In that case the saved data
[appliances] => L_Refrigerator,Fan,PC
needs to be converted back into an array before your PHP will work on it.
Bob
Hi Faitas,
Please try
Bob
Please try
$form->data['appliances'] = explode(',', $form->data['appliances']);
Bob
This topic is locked and no more replies can be posted.