Forums

Pull variable list from database to a dropdown list

NJM 31 Aug, 2015
Hi,

I read a lot of ways to try this on the FAQ but I don't seem to make it 'till the end.
In my DB is a list of products. I want to show these products in a dropdown list.

I've created a form with a dropdown field. On the SETUP-part, befor the HTML render, i've added an "DB read" which is linked with my database. There Ive chosen "external database" and selected a table. Then, i'm kinda lost. I need to set the ModelID? can I choose which name that is? After, i go to the dropdownfield. I click on "dynamic data". and than I need to fill in data path I guess. What is the correct way to add this then?

Thanks for helping me out,
kind regards,
Djiep Ly Mai
GreyHead 01 Sep, 2015
Hi Dijep,

You get to choose the Model ID - a short string like 'products' - then put the same string in the Data Path in the Dynamic Dropdown settings.

Bob
NJM 01 Sep, 2015
Hi Bob,

Thanks for your add. Doesn't seem to do the trick yet. This is my contruction:

On Designer:
Basic: Dropdown.
When openend via edit,
> on tab Dynamic Data
- Enabled: Yes
- Data Path: Products (some string, but the same)
On Setup:
OnLoad > DB Read.
When opened,
> on tab 'External Database: linked to your own database with an ID & Name
> on tab Basic:
- Enable Model ID: Yes
- Model ID: 'Products' (some string)
- Fields: ID, Name
GreyHead 01 Sep, 2015
Hi Djiep ,

Please remove any quotes round Products if you have them in the Model ID

Bob
NJM 02 Sep, 2015
I don't
Any other ideas? Thanks!
NJM 02 Sep, 2015
i couldn't find the edit button on previous posts, so i wasn't able to remove the quotes from my example
GreyHead 02 Sep, 2015
Hi noeljm,

Please drag a Debugger action into the On Load event, then submit the form and post the debug results here.

Bob
NJM 30 Sep, 2015
Hi,

Sorry for the delay, been caught up.

> The array is loaded with the content from the database. I've cut the list in the debugger. But that content doesn't appear in dropdownbox.

Here's my debugger.

Data Array
Array
(
    [option] => com_content
    [view] => article
    [id] => 86
    [Itemid] => 307
    [lang] => nl
    [Products] => Array
        (
            [0] => Array
                (  [Short_Desc_FR] => Accidents du travails )
            [1] => Array
                (  [Short_Desc_FR] => Aptitudes  )
            [2] => Array
                (  [Short_Desc_FR] => Auto  )
            [3] => Array  ( [Short_Desc_FR] => Incendie  )     

)

Array
( )

Errors
Array
( )

Debug Info
Array
(
    [17] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                        )

                )

        )

)
GreyHead 30 Sep, 2015
Hi Dijep,

In your earlier post you have put ID and Name as the fields - but neither of these are in the Products array you are reading from the table. What do you want to have as the drop-down values and text?

Bob
NJM 30 Sep, 2015
Hi,

i've changed the field I want to load.
Fields: Short_Desc_FR

It's shown in the array
( [Short_Desc_FR] => Accidents du travails )

I want the array/ist of [Short_Desc_FR] => Accidents du travails to be shown in the dropdown, which now is empty.

Thanks, again.
GreyHead 30 Sep, 2015
Hi Djiep,

On the Drop down element Dynamic Data tab please put:

Products in the Data Path Box, and
Short_Desc_FR in both the Value key and Text key boxes.

Bob
NJM 15 Dec, 2015
Hi,

Any other ideas on this matter?

Thanks in advance
GreyHead 15 Dec, 2015
Hi noeljm,

No.

Bob
NJM 15 Dec, 2015
OK...

So then I just can't add a link to a table...
Guess I'll just copy 1200 lines to chronoform then
GreyHead 15 Dec, 2015
Hi noeljm,

It should work correctly with the settings I gave you. There's no other info in your post to tell what might be gong wrong.

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