Forums

problems with my DropDown

Fredolino 28 Feb, 2019
Hello,

I have field and have to get used to CF6 first.
The data comes from a database which is loaded with "Read Data".
I have already changed the "Select type" several times and entered different values in "Fields to retrieve" but I have never seen anything in the drop down box.
The excerpt from the debugger outputs this.

Do I have to enter a code in the field "Where conditions" or a PHP script into a "Custom Code"?
Or do I have to change in the option field {var: read_data15)?
I want this view in the DropDown field (example):

pruni (Denis & Schiffermuller, 1775), Rhagades

Many thanks for your help.

many Greetings
F.


healyhatman 28 Feb, 2019
You need to change it to "Return an array of key/value pairs" and you need only two fields in the Fields to retrieve - the VALUE the dropdown option will be and the LABEL for that option. E.g.
id
author
Fredolino 01 Mar, 2019
Hello,

Thank you for the info.
I have tried it but still no data is displayed.
What am I doing wrong?
I have 2 screens to watch.
Here is my test form. It is the 1st drop down above
http://simon.sommerfugl.de/index.php/funde-melden
many Greetings
F.
healyhatman 01 Mar, 2019
Answer
1 Likes
You put the read data before the display form action, right?
Fredolino 01 Mar, 2019
Ouch! that hurts ...
Now I will see something unformatted in the dropdown ….
Fredolino 01 Mar, 2019
I now have this in the option field:
= Art auswählen
{Var: read_data15 / (var: default_if_not_found)}
and with extra attributes:
class: search
autocomplete: on
If I see in the frontend in the source code, but still stands
autocomplete = "off"
Is this a mistake?

Can I display the values from 2 additional columns of the DB table in the dropdown box?
//echo $ row ['art']. "". $ row ['autor']. ",". $ row ['gattung'];

Do I have to make a "Custom code" in front of "Display Form" or a "PHP Code" after "Display Form"? the PHP code with {var: php17} in the option field?
Or does a shortcode work?
{var: read_data15} {var: autor}, {var: gattung}
Output in the dropdown lines as an example:
pruni (Rothschild 1917), Lasiocampa

F.
healyhatman 01 Mar, 2019
Get rid of "{var:defaultifnotfound}".


And yes, use CONCAT(field1 , ' ' , field2) in fields to retrieve . Note the spaces around the commas.
Fredolino 02 Mar, 2019
Hi,
that with CONCAT worked!
I am absolutely enthusiastic about CF6. :-)

In the option field I tried a few variants.
That's in it:
{Var: read_data15 / var: defaultifnotfound}

The source code is still in the input tag
autocomplete = "off"
But it works anyway.
I am shown the correct data after 3 letters and the message "No results found" appears.

many Greetings
F.
healyhatman 02 Mar, 2019
Get rid of /var: default if not found, it's wrong syntax.
Fredolino 02 Mar, 2019
I'm sorry, I do not understand ...

{var:read_data15/var:default_if_not_found}
{var:read_data15/var:defaultifnotfound}
{var:read_data15/var:default if not found}
{var:read_data15/{var:default_if_not_found}}
{var:read_data15{/var:defaultifnotfound}}
....
does not change autocomplete = "off" in the source code ..
healyhatman 02 Mar, 2019
Get
Rid
Of
/var default if not found
It's not necessary or correct
Autocomplete=off refers to something else.
Fredolino 02 Mar, 2019
har har :-) ok!!!
🤣
This topic is locked and no more replies can be posted.