ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Populate field value after selecting value in dropdown

Carmiel 15 Sep, 2019
Hi dears,
I try to do something that sound very simple reading faq and forum, but for sure it miss me something to success.

I have a database table containing travels list with ID, code, destination, startdate, enddate and so on.
I retrieve data by an action read_data giving read_data19

I populate a dropdown with list of destinations (this work).
Now the visitor need to select a destination, it should trigger the field "code" by a reload, I need to display informations.
For the moment I try only with the code but it doesn't work. I tried lot of possibilities, but for sure not the right one.

In fact, the question is probably, what should be in the field "value" of the field "code" ?

Thank's for your help.

(cannot upload images, here they are)
https://drive.google.com/open?id=19rCK5nK6FeWUMx-cjLbcKaJFDcqr9ObL
https://drive.google.com/open?id=18-pOIX_BDG8wY9cB2Ln6KuWNqfLlGoYU
https://drive.google.com/open?id=11maqf7BR3J8yh9_9C8ECrPO4WrOZZc-8
healyhatman 15 Sep, 2019
Select Type: Return an array of key/value pairs, TWO FIELDS MUST BE PROVIDED. You've provided 6.

Is there a particular reason you want to put a value in the text field, which the user can then change, instead of just using the voyage code and sending reading the correct entry from the database on submit?
Carmiel 16 Sep, 2019
Hi, thank's for answer.
It is "return an array..." but specifying 2 fields doesn't change anything.
I want to display details to the subscriber.
Anyway I need to get the code to send it by mail and based on the same mecanism I will also need to send firstname/lastname of subscribers ID of participants (not the connected profile).
healyhatman 16 Sep, 2019
You need a reload action for the fields you want to change when you change the dropdown. Have a look at the dynamic dropdown demo, it's the same idea.
healyhatman 16 Sep, 2019
The code will be something like {var:read_data#.model.field}
You need to read the database based on the field that's triggering the reload, with the data read set to first matching.
healyhatman 17 Sep, 2019
Which part are you having trouble with exactly, what have you tried, what have you put in the value? Is your reload event set to standalone, with auto display view turned off?
Carmiel 18 Sep, 2019
OK, I tried to do it again step by step trying to adapt then https://www.chronoengine.com/forums/posts/t105344/fill-text-from-a-dropdown-db-read
First step, I want to retrieve the code depending of the destination selected in the dropdown. Later I will see for others informations.
this I did :
Result : something happen when I select a destination in the dropdown, title goes grey color and a grey circle turn but no code value in the field.
You have a dropdown, let's call it "selected_destination".
Under "events", you want On: change, Actions: reload, Identifier: code
I will assume you already correctly set up the read data actions in your load event to dynamically populate the dropdown (yes it is, I display destination).
[color=rgb(255, 0, 0)][mark]Options : = (line to get an empty line first)
{var:read_data19}

read_data19 : Return an array...
Model name : Liste
Fields to retrieve
code
destination[/mark][/color]

You have a text field, let's call it "code".
Under "advanced", you want Reload event: reload_code

You have a database table called xx_my_data, with three fields: id, name, flavour =>>> id, destination, code.

Under the "Setup" tab at the bottom of the page, create a new event called "reload_code".
in fact I was stucked here because with "New V6.1 mode" you add a Page, not an event. I have looked in old Form they are in "V6 classic mode" and have "add en event"
and it seems there is no way to change it throw front end, so I modified it in the sql table. Seems to work

You then want a Read Data action, with your table selected, and call the model "Destination".
* Where conditions: Destination.id:{data:selected_destination}
* Fields to retrieve: Destination.code [br]* Select type: first matching record[br]I have added a "Rule list" in Where conditions[br]Then you need a PHP action (under "Logic"). Replace "action_name" with the name of the read data action, the text in the black Name box. It should probably be "read_data20" or something along those lines.[br]$this->data("code", $this->get("read_data20.Destination.code", ""), true);[br][br]Lastly, you need a Custom code action, with:[br]{view:field_text58} where text_field_view_name is the Name: in the black label of the field.
healyhatman 18 Sep, 2019
in fact I was stucked here because with "New V6.1 mode" you add a Page, not an event. I have looked in old Form they are in "V6 classic mode" and have "add en event"and it seems there is no way to change it throw front end, so I modified it in the sql table. Seems to work
In the new builder, you should add a page and set it to STANDALONE and make sure that Auto Display View is switched off.
then you need a PHP action (under "Logic"). Replace "action_name" with the name of the read data action, the text in the black Name box. It should probably be "read_data20" or something along those lines.
This probably doesn't apply to your situation.
Carmiel 18 Sep, 2019
This probably doesn't apply to your situation.
Why do you say that, the exemple sound exactly my need ?

I put a debugger in the reload_code event and nothing happen. Seems like it is not triggered
healyhatman 18 Sep, 2019
What else have you done for your reload event? The other things I said? Auto display view is off, page is set to standalone?
Carmiel 19 Sep, 2019
I success to do something,
first I have corrected the filter in the read_data20 action because it was "code = {data:selected_destination}". ok seeing with debugger that it was getting the right value
I tried {view:field_text58} to {view:field_text62}
but it write the first in the field_text and the other just under. field_text59 to 62 stay empty.
So I did 5 events (like reload_code but returning next field), each one for a field.
OK it work but it is low speed, 5 events is not performance oriented.
Last thing, I say it work, but only by "Preview", when executing by the front end I have grey running circle
Preview : https://drive.google.com/open?id=1dLs5QgKTWCBWfOQIJs4JKVhsM17f2SDE
Running : https://drive.google.com/open?id=1LqUUtTXP2s2FfWIPVj8jxyzHy22Q0kGS
So values are here, but not working properly
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com