Forums

Save Text Key Dynamic Dropdown

Yudhizth 15 Dec, 2014
Hi all,

I don't understand how to save text key on dynamic dropdown, I follow the instruction from this FAQ https://www.chronoengine.com/faqs/70-cfv5/5232-how-do-i-build-a-dynamic-drop-down-in-cfv5.htmlhttps://www.chronoengine.com/faqs/70-cfv5/5232-how-do-i-build-a-dynamic-drop-down-in-cfv5.html

I already create chained dropdown reference by that FAQ, but, it's only save id of province , county , district, village. Not the name of them, so, how to save id and name by using dynamic dropdown?

Thanks
Yudhizth 16 Dec, 2014
Thanks Bob,

I still confused, Do we have to create custom code on submit action or what?
GreyHead 23 Dec, 2014
Hi Yudhizth,

Yes, probably, there isn't enough information here to give a better answer.

Bob
raffru 28 Apr, 2015
Hi Bob,
I have the same issue.
Three dynamic dropdown that work perfectly (regions, cities, villages).
In order to save text (region) I have added an hidden field(regione) to keep text value and put in OnSubmit section the following code (input_select_reg is the region drop down).

<?php
$regioni = array(
1 => 'Marche',
2 => 'Abruzzo',
3 => 'Basilicata',
4 => 'Molise',
5 => 'Trentino Alto Adige',
6 => 'Puglia',
7 => 'Calabria',
8 => 'Campania',
9 => 'Lazio',
10 => 'Sardegna',
11 => 'Sicilia',
12 => 'Toscana',
13 => 'Piemonte',
14 => 'Emilia Romagna',
15 => 'Friuli Venezia Giulia',
16 => 'Valle d''Aosta',
17 => 'Veneto',
18 => 'Liguria',
19 => 'Lombardia',
20 => 'Umbria'
);
var_dump($regioni);
form->data['regione'] = $regioni[$form->data['input_select_reg']];
?>


With debugger I can't see $regioni array and the field regione is empty.

Please can you help me?

Thank you.
Max_admin 28 Apr, 2015
What does the debugger show for the value of "input_select_reg" ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
raffru 29 Apr, 2015
The value for "input_select_reg" is 2 in my test and "regione" is still empty:
Data Array: 
Array
(
    [option] => com_chronoforms
    [chronoform] => SCARICABUONOSCONTO-PROV-Copy
    [event] => submit
    [Itemid] => 
    [lang] => it
    [input_text_3] => Raffaele
    [input_text_4] => Russo
    [input_text_7] => raffru@gmail.com
    [input_select_reg] => 2
    [input_select_prov] => 44
    [input_select_com] => Altino
    [regione] => 
    [input_checkbox_17] => 1
    [chrono_verification] => 2bqur
    [Invia] => Invia
    [838163de85b4883189707e66763c5c73] => 1
    [language] => it-IT
)
GreyHead 29 Apr, 2015
Hi raffru,

You are missing the $ at the start of this line
$form->data['regione'] = $regioni[$form->data['input_select_reg']];

Bob
raffru 29 Apr, 2015
Hi,
doesn't work😟

$regione still empty.

I can't see $regioni on the screen, is var_dump($regioni) the right command?
I think that this array is not stored correctly, how can we watch the array?
GreyHead 29 Apr, 2015
Hi raffru,

Please post a link to the form so I can take a quick look.

Bob
raffru 29 Apr, 2015
Here is:
https://www.quattrozampeinfiera.it/it/?option=com_chronoforms&chronoform=SCARICABUONOSCONTO-PROV-Copy

The form will send an email to your address with an attachment (just to know😉 ) saving the data.

Thank you.
GreyHead 29 Apr, 2015
Hi raffru,

That all looks OK apart from the missing regione. By all means PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look.

Bob
raffru 29 Apr, 2015
Hi Bob,
I need to have an approval from the client before send to you the admin credentials (I hope that you will know).

Can I, in the meantime, send you a backup of the form?
GreyHead 29 Apr, 2015
Hi raffru,

A backup is fine, post it here if that's OK.

Bob
raffru 29 Apr, 2015
Ok, please take a look the file Attached.

Thank you.
GreyHead 29 Apr, 2015
1 Likes
Hi raffru,

This line is a problem:
  16 => 'Valle d''Aosta',
See the extra quotes in the middle. The simplest fix is to change this here and in the drop-down options to say Valle dAosta - the Text part after the = can stay the same.

Bob
raffru 29 Apr, 2015
Great!
I'm very sorry for the error.

Now, I will remove the array and will try to use a DB lookup table (the same DB table used in the dynamic dropdown).

Thank you.
This topic is locked and no more replies can be posted.