Dynamic options for dropdowns and multi selection fields

Discover how to load Dropdowns and Checkboxes options from your Database or other dynamic sources in your Joomla form using ChronoForms8.

Here is how to setup the Dynamic Options behavior for the dropdown fields and multi selection fields in ChronoForms v8, the same setup can be used for Chronoforms v7

Start by preparing your options array, your can do this using:

  1. PHP action if your have a static or complex source of data
  2. Read Data action action if your options are coming from the database directly

PHP action settings

Dynamic options for dropdowns and multi selection fields image 1

The PHP actions will return an array with options values and texts

Next, enable the Dynamic Options behavior in your dropdown and set the Data Source as {var:php25}, which in this case is the returned value from PHP action named "php25", the action we have just created

We will also need to set the Option value path to: {row:value} and the Option value text to {row:text} as this is the path for the values and texts in our array:

Dynamic options for dropdowns and multi selection fields image 2

You may add any default options to the Options box, those will appear before the dynamic options.

Read Data settings

Dynamic options for dropdowns and multi selection fields image 3

And your dropdown Dynamic Options will change accordingly:

Dynamic options for dropdowns and multi selection fields image 4

  1. We use the results of the action named "read_users" as the Data Source
  2. We use the row's id value for the option value, each row coming from the users table will have an "id" column value
  3. We use the row's username value for the option text, each row coming from the users table will have a "username" column value

v8.0.47 Update

if you have ChronoForms v8.0.47 or later, you may also use {row:key} and {row:value} if your values are a single dimension array, coming from a JSON array in the database for example:

Dynamic options for dropdowns and multi selection fields image 5

in this case {row:key} will hold the numeric value index, and {row:value} will hold the value itself

Category: ChronoForms v8

Comments:

You need to login to be able to post a comment.