Fields to retrieve - read data

How to populate a dropdown with city names from a database table.

Overview

The issue occurs when configuring a CF Read Data control to fetch data for a dropdown.
Set the 'Select type' to 'Key/Value pairs' and enter the column name containing the city names in the 'fields to retrieve' field. Then, reference the control's variable in the dropdown's options.

Answered
ChronoForms v6
Da Daniele.Ruggiero 13 Dec, 2017
Hi,
i have a mysql table (named Comuni) with all the italian city. I have to populate a dropdown control (named Citt) with the names of city.
Using a read data (read_data15) control, which values goes in 'fields to retrieve' field?
Please see also the screenshot attached.

structure of table Comuni:

CREATE TABLE IF NOT EXISTS `comuni` (
`Istat` int(6) default NULL,
`Comune` varchar(35) default NULL, ----> name of city
`Provincia` varchar(2) default NULL,
`Regione` varchar(3) default NULL,
`Prefisso` int(6) default NULL,
`CAP` varchar(5) default NULL,
`CodFisco` varchar(4) default NULL,
`Abitanti` int(7) default NULL,
`Link` varchar(38) default NULL
)
Max_admin Max_admin 14 Dec, 2017
Answer
Hi Daniele,

In the "Select type" please use "Key/Value pairs" and in the fields to retreive just use "Comune"

Then use {var:read_data15} in the options box of the dropdown!

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
to touretteroma 22 Apr, 2018
Dear all,
using {var:read_data15} returns a structure like {"Roma":"Roma"}.
How to get just the value "Roma" to be used sending an email?
I'm trying to get value using {var:read_data15[0]} or {var:read_data15['0']} or {var:read_data15['Comune']} but I always obtain an empty string
Please, could you help me?
Gr GreyHead 22 Apr, 2018
Hi touretteroma,


I think that you are trying to do something completely different - this thread is about reading data to populate a drop-down. You should be able to get the selected value of the drop-down using {data:input_name}

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