Buy Now
Sign in

load data from DB with url request param/token (CF6)

hekla , June 17 2017
H
hekla
Hi

first of all: thank you for chronoroms and all the possibilities, that come with it!

I would like to create an event registration form in chronoforms 6 and ask for support for some issues.

I have a DB table with the events details such as titles, prices etc and I want to load the data into the form (DBRead) with help of an param/token in the url.
I have tried a lot of possible solution I found in the forum and the howtos, but I had no success – maybe because most of them are for CF4 or CF5.

The situation:
Let's say I have an url:
https://www.domain.tld/registration.html?event_id=34

and a table with the event details, jos_chronoengine_events with the following fields:
id (key), event_id (varchar), event_title (varchar), prices_adult (array like {"300":"300","200":"200"} or {"500":"500"}) … (and some more, which are not of importance a this time)

With the event_id in the url I would like to load from the DB the data with the same event_id:
1) the event_title in a dropdown menu (with the event title as single preselected entry)
2) the array of the prices_adult in a dropdown menu (with one two or three entries) and the first price is preselected

So how do I do this in CF6 (not CF5 or CF4).
As I'm not a real coder I possibly need instructions for dummies …

Thank you
Hekla
GreyHead
Hekla,

In the DB Read action Where conditions box please try event_id:{data:event_id} or event_id:{url:event_id} - I'm not sure if the URL variables are added to the data array or the url array.

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
H
hekla
Thank you Bob.

A follow up question:
and how do I load the data into the dropdown menu?
I couldn't figure that out …
admin
Hi hekla,

If your Read Data action "Select type" is set to "Key/value" pairs then you can just add the following shortcode to the "Options" box in the dropdown:
{var:read_data_name}


Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
H
hekla
Thank you Max,

somehow I don't do it the right way – the dropdown menu stays empty.
It seems I really need basic instructions for chronoform beginners, sorry!

my questions:
    I guess I have to replace "read_data_name" in {var:read_data_name}, but with what exactly?
    How does the dropdown menu "know" that I want the content of the DB field "event_title" to be loaded?
    Are there other settings/params I have to set correctly (there are so many of them)?

Thank you.
admin
Hi hekla,

"read_data_name" is the name of the "Read data" action, please check this FAQ:
https://www.chronoengine.com/faqs/74-chronoforms6/5287-dynamic-dropdown-options.html

If you still can not get it to work then please let me know and I will prepare a tutorial with images.

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
H
hekla
Hi Max,

Thanks. Unfortunately I still don't get it. The FAQ seems clear, but the dropdown menues stay empty.
A tutorial would be great, also for potential successor.
And I'm also happy to let you look at the form and to pay for your service.

Greetings
Hekla
admin
Hi Hekla,

Please send me a message using the "Contact us" page to get a link for the latest manual revision which should hopefully help.

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
H
hekla
Max, thank you for the manual! It helped me to take some steps and to understand chronoforms some more.
I succeeded to get DB Read to work – it loads the correct event title and price according to the request params in the url.

I did not succeed though with dispalying the retrieved data correctly:

Question 1)
When I load the event title into a dropdown menu, then it is displayed correctly: This is my event title
When I load the event title into custom html, then it isn't displayed correctly: {"This is my event title":"This is my event title"}
How can I display it in custom html in the way: This is my event title?

Question 2)
For each event I have an array in the DB with the prices to choose from, e.g. {"230":"230","170":"170"} or {"290 - Privat":"290","350 - Non-Profit":"350","450 - Business":"450"}'
How can I load them into a dropdown menu as label:value pairs to choose from?

Thank you.
admin
Hi hekla,

What is the format of the data stored in the database table in both cases ?

What is the shortcode you have used to output the data ?

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
H
hekla
Hi Max,

in question 1 it is it a varchar field and just the text: This is my event title

in question 2 it is an array, displayed as saved in den DB: {"230":"230","170":"170"} or {"290 - Privat":"290","350 - Non-Profit":"350","450 - Business":"450"}.
The formatting of the array in the DB does not necessarily have to be like this – it can easily be changed. When you say its better to have it in a different format then I can do it (the table is filled once a year for the whole event season)

Thank you
Hekla
admin
Hi Hekla,

I think that you using a wrong "select type" in the "read data" settings.

Did you check the "Read data" section and the "shortcode" section in the manual ? they explain the data returned and how to extract what you need.

So for the custom html you will need to set the select type to "first matching" and the shortcode should be {var:read_data_name.Model.field}

For the dropdown options you need to set the select type to "key/value pairs" and set the options setting to {var:read_data_name}

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
H
hekla
Hi Max

I went through the manual again – still learning and improving :-)

For the dropdown options you need to set the select type to "key/value pairs" and set the options setting to {var:read_data_name}

I did it, but the output stay the same, e.g. {"230":"230","170":"170"}
Or do I need to have them in a different way in the DB?
I just did it like param arrays are represented in Joomla

An other question:
I need all the information in the DB which is called by the request param.
Do I need to have an extra DB Read for every cell in the DB of is there a way of combining it?
For instance: I already get the event title with {var:read_data_name.Model.field} and Select type to "First matching record".
Is it possible to get the price array with the same DB Read, even though select type is set to „key/value pairs“?
admin
Hi hekla,

Apologies, I forgot to reply here earlier, please let me know the current issues you have.

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
H
hekla
Hi Max,

no problem and thanks for coming back.

my main question is:
in which format should the data in the DB be saved, that I get a dropdown menu.
I have one to four values there – depending on with table is loaded – and I would like to get a dropdown menu with these options.

And I have been preparing a requirement list for my form and will ask you for a payed job soon.
H
hekla
Hi Max

I just sent you and Bob a detailed description about my form and a request for a quote by email.

Thank you
Hekla
H
hekla
Hi Max,

I would appreciate to get some support.

1)
Could you please give me an information, if the form, how I would like it is possible with CFv6 and if you can do it.
I need the form by mid of September and would have to find an alternative like paid service at Breezing Forms or similar – but I would prefer to stay with chronoforms.
I attach the form description here again.
As I said, I willing to pay for support – I just need it.

2)
or at least if I could get a solution for my main question
in which format should the data in the DB be saved, that I get a dropdown menu.
I have one to four values there – depending on with table is loaded – and I would like to get a dropdown menu with these options.


Thanks,
Michael
Attachments
Event_Registration_Form_Chronoforms6.docx
(506.21 KiB)
64 Downloads/Views
admin
Hi Michael,

You need a dropdown "menu", like a website menu ? or just a dropdown field ?

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
H
hekla
Hi Max

Oh, I'm not sure about the difference. Just have a look at
https://registration.zegg.de/en/?event_id=17101 under "Price", right on the top.

And in fact, I also need the same with radio buttons like under "Accommodation" in the given form.

Thank you.
admin
Hi hekla,

So you need to populate the dropdown with the read data values, you need to use the request parameter in the "where conditions" of the "read data"
table_field:{data:url_param}

And then set the "select type" to "key/value" pairs
Then go to your dropdown and set the options to:
{var:read_data_name}

This is explained in details in the manual available on the downloads page!

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!