dynamic dropdown

Populate a dynamic dropdown field from a database record.

Overview

The dynamic options code returns a single array instead of a list of options.
Update the PHP code to return an array of arrays, each containing 'value' and 'text' keys for every database value.

Answered
ChronoForms v8
kr kraadde 30 May, 2025

I have a database record "einsteige_ort" with following 1 to 8 values:

["Ruetihof","Gebenstorf","Trafo","Schademuehle","Eurobus","Lauffohr","Bahnhof","X"] that I want to populate a dropdown field "zusteige_ort"

I have a php96 like that:

$options =  ['value' => $this->data("einsteige_ort"), 'text' => $this->data("einsteige_ort") ];return $options;

and the Dynamic Options set as {var:php96}.

It does show an empty field. How to solve?

The FAQ "Dynamic options for dropdown and multi selection fields does not gives me enough information. Could you help?

BDW: a read data option is indeed included.

Post a Reply