Occasionally in the CFML Slack channel (and the IRC room before it) someone asks about a
valueArray() function - what they mean is that they want something like the terribly named
valueList() that you can provide a query and a column and get a column slice which will return an array instead of a CFML list.
valueArray() exists on Lucee but for ACF you’re stuck implementing it for yourself. Here is a way to do that properly (it’s easy to do it naively wrong).
This requires dropping down into java reflection territory, but the benefit is that it actually adds things to the array directly, value by value. This means that everything works no matter what the value is - commas in the values are problematic for using
valueList() and then something like
You can see it in action on trycf.
2015-02-16 Update: this just in, ACF 2016 has added
valueArray() - with the same signature and everything. This function will still be useful for earlier versions though.
Subscribe via RSS