• 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 Eval Populate list view display

achartier

Super Moderator
Staff member
When populating a dropdown using the eval populate function, the result does not seem to display correctly in list view. In my list view it always displays as the first item of the dropdown no matter which item was selected. If I view or edit the record the value is displayed correctly and it is correct in the database.

Something not quite right in the list view display.
 
Found the problem. Questions is should it operate this way or not.

Issue is that when I build the select.option list in the php eval code I set the first entry to a "Please select" with a value of 0 (zero). The rest of the select.options come from the DB. What is happening is that the first option has a type of int(0) whereas the rest of the values are type string. Normally this should not be a problem.

However, in components/com_fabrik/models/element.php at line 4100 (or thereabouts depending on githjub version) is a statement $key = array_search($v, $values); when the values are of mixed type as a result of the select.options values and this function is returning an integer zero ($v is a text string at this point and is the select text). As a result when displaying the table in list view the element is always showing the first item of the select.option list which in my case is "Please select".

I can correct this by changing the zero to a string of zero ('0'), or if I force the array_search to strict by adding true as the third param of the call then it works for me.

Which is the correct way to solve this? I imagine others will stumble into this at some point.
 
setting the select.option to a string 0 is in my eval code, the array_search is in the model.
 
I'd say just set it to a string in your eval code. I think we make the assumption in several places that select values are always going to be strings.

-- hugh
 
OK. At least if this comes up for someone else they will hopefully find this posting.

Thanks.
 
If one of us was feeling super keen, we could add it as a warning at the bottom of the dropdown element wiki page ... hint hint ...'

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top