Forums

Dynamic dropdown inside area repeater

Gangrel 27 Mar, 2019
Good morning
I tried to create a Dynamic dropdown in my form (I got inspiration from the demo).

My form has 4 fields inserted into an "area repeater".
the name of the first is: Model[{var: area_repeater6.key}][description_materiale]this is an autocomplete dropdown, which works thanks to your help:
http://www.chronoengine.com/forums/posts/t106946/where-conditions-for-a-dropdown-autocomplete-inside-a-repeater-area

the second field is always a dropdown called: Model[{var: area_repeater6.key}][um]
my goal is to change the value of Model[{var: area_repeater6.key}][um] when changing the value of Model[{var: area_repeater6.key}][description_materiale] dynamically

for now I did this:
On the "design" area I went to the Model events tab of Model[{var: area_repeater6.key}] [description_materiale] and filled in as follows:
on = change
actions = reload
element (s) identifier = Model [{var: area_repeater6.key}] [um]

in the dropdown Model[{var: area_repeater6.key}] [um]
in general tab:
Options= {var: umvalue}
in the Advanced tab
reload event= um_read



in the "setup" area, I created a new event called um_read. inside I put a php code called umvalue with this code:

$descrizione=$this->data("Model.[n]")[0]["descrizione_materiale"];
$db = \JFactory::getDBO();
$sql = "
SELECT um
FROM SA_schede_materiale
WHERE descrizione_materiale = '".$descrizione."'";
$db->setQuery( $sql );
$misura= $db->loadResult();
return $misura;

and after the php code I inserted a "custom code" with this: {view: field_select26}
(field_select26 refers to the dropdown Model [{var: area_repeater6.key}] [um])



in this way, the autocompletion works only for the first Model[{var: area_repeater6.key}][um] of the area repeater,
when I add other fields by pressing "add" the UM value of the following ones is always the same as the first one.
How can I make the autocompletion work for all the "UM" fields of my area_repeater?




thank you so much
healyhatman 27 Mar, 2019
Well you're using (model.[n])[0] so that would be you telling it to get the first one, right?
Gangrel 27 Mar, 2019
Hi, Thank you for reply🙂

I'm using (model. [n]) [0] as in the answer to my previous support request:
http://www.chronoengine.com/forums/posts/t106946/where-conditions-for-a-dropdown-autocomplete-inside-a-repeater-area
in that case it worked well

To make it work in this situation, what can I replace it with?

to better explain my situation. This is my form:



the first line:
descrizione materiale: abc
unità di misura: N

it's right

the following
Descrizione Materiale: edf
unità dimisura: N
Descrizione Materiale: qwerty
unità dimisura: N
Descrizione Materiale: asd
unità dimisura: N

they are wrong because the N value in "unità di misura" just matches "descrizione materiale: abc"
This topic is locked and no more replies can be posted.