Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm not sure if this is a bug or if I'm doing something wrong here. If you manually enter the options, the following applies:
"Enter one value per line, in the format key|label."
This does not seem to apply when choosing PHP Code to return an array. If I return my values in the form of key|label in an array it will print just that in the dropdown. I tried filling the array with $option[][key] and $option[][label]s but that doesn't work either.
So in short: is it possible to define a label and key when using PHP Code, and if not: was this intended or is it a bug?
Comments
Comment #1
wmostrey CreditAttribution: wmostrey commentedThanks to chx for pointing me out that the correct way of handling this is to use $items[$key]=$label;
Comment #2
StephenRobinson CreditAttribution: StephenRobinson commentedI have found the best way of implementing this is to create a view that produces the key|label syntax, then steal the sql statement.