Dropdown Eval Populate list view display

achartier

Administrator
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

No members online now.
Back
Top