• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Dropdown Populate Basics

Status
Not open for further replies.

billvv

Member
I am trying to create a dropdown menu using a table to populate the dropdown selection options. The dropdown element appears on the form but it is blank. Here is my code, basically taken from the wiki example:

Code:
$options[] = JHTML::_('select.option', '0', 'Please select' );
$db = JFactory::getDbo();
$db->setQuery("SELECT id, region FROM oc_regions");
$rows = $db -> loadObjectList();
foreach ($rows as $row) {
    $options[] = JHTML::_('select.option', $row->id, $row->region);
}
return $options;

I ran the code in a little php script and verified that the $options array is populated:

Code:
phpArray ( [0] => stdClass Object ( [value] => 0 [text] => Please select [disable] => ) [1] => stdClass Object ( [value] => 1 [text] => Red Rock [disable] => ) [2] => stdClass Object ( [value] => 2 [text] => Calgary [disable] => ) [3] => stdClass Object ( [value] => 3 [text] => PacNW [disable] => ) [4]

etc.....

The sub-options under 'Data' have been left empty. I'm sure it's something basic that is preventing the sub-options from appearing, but I sure can't find it.
 
Should do.
What is your exact Fabrik version?
What are your dropdown element settings?
 
Running Fabrik 3.2

Data - Sub-Options: blank, Multiple Selections: No
Front End Additions - Enable, Only Add Label, Save New Additions: No
Advanced - Separator: blank, Eval Populate: code cited above
Formatting - Bootstrap Class: input-medium
Options - Default: blank, Eval: No

I don't see how this script distinguishes between sub-option 'Values' and 'Labels'. I'm beginning to suspect that the Separator field separates them, and that the data picked up from the external table needs to take the form 'some Value <separator> unique Label' based on the order in the Data menu. I don't see any other way that both parameters can be loaded.

Also curious why the values for $row->options have the string '[disable]' appended.
 
Last edited:
Recent Fabrik version is 3.4.2 and eval populate is working.

If your dropdown values are disabled this is not Fabrik.
Which Joomla template are you running? Maybe your template or some 3rd party plugin is injecting.
Is it working in the backend?
 
Recent Fabrik version is 3.4.2 and eval populate is working.

If your dropdown values are disabled this is not Fabrik.
Which Joomla template are you running? Maybe your template or some 3rd party plugin is injecting.
Is it working in the backend?

Does the string [disabled] mean that the dropdown values are disabled?
I don't have any Fabrik 3rd party plugins installed.
The site template is Gantry. The form template is bootstrap.
Don't know how to run a form in the backend; probably simple, I just haven't figured it out.

How would this code:
Code:
 $options[] = JHTML::_('select.option', $row->id, $row->region);
Insert the parameter [disable] when I print the object:
Code:
print_r($options);
and get the result:
Code:
Array ( [0] => stdClass Object ( [value] => 0 [text] => Please select [disable] => ) [1] => stdClass Object ( [value] => 1 [text] => Red Rock,Red Rock [disable] =>
It looks like there are three parameters: [value],[text], and [disable] returned. Are you saying that the JHTML::_ statement (what ever that does??) allows some other outside 'influencer' to add the third parameter?
 
JHTML is creating something like
...object(stdClass)#1364 (3) {
["value"]=>
string(2) "41"
["text"]=>
string(3) "abc"
["disable"]=>
bool(false)
...
No idea why your [disabled] is not set.
You are running an outdated Fabrik version, which Joomla version are you running?

Update to recent versions, try with the Protostar template coming with Joomla.
 
I'm pretty sure Joomla is out of date as well. We'll back up and update, change to Protostar, try again, and report back.

Thanks!
Cheers, billvv
 
Thanks for reporting back.
You can close solved threads by unchecking "open" in Thread Tools.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top