Forums

I Want to set dropdown List in pageLoad php

firstohmICD 22 Nov, 2024
$options = [];$options[] = ['value' => '', 'text' => '請選擇'];

$options[] = ['value' => '1', 'text' => '1'];

$options[] = ['value' => '2', 'text' => '2'];

$this->data['dropdown_Type'] = $options;

This is my PHP code, I Want to set dropdown List in PHP at page Load,But it is not successful and effective.

Max_admin 22 Nov, 2024
Answer

you need this code in a PHP action ABOVE the Dropdown field, then you need to configure your dropdown like this:

where "php_name" is the name of your PHP action, also your code should be like this:

$options = [];
$options[] = ['value' => '', 'text' => '請選擇'];

$options[] = ['value' => '1', 'text' => '1'];

$options[] = ['value' => '2', 'text' => '2'];

return $options;

tutorial here:

https://www.chronoengine.com/faqs/chronoforms/chronoforms8/dynamic-options-for-dropdowns-and-multi-selection-fields

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.