I was just wondering the reasoning behind the following code:

foreach($element['#options'] as $key => $val) {
      if (!is_numeric($key) || !is_string($val)) {
        return $element;
      }
    }

This stops 2 of my multiselects from being transformed as the keys are strings. I have commented out the "return $element" line and it seems to work ok, was this implemented for a reason?

Comments

agileware’s picture

Title: Why does the multiselect key need to be numeric? » Add support for text type select fields
Category: support » feature

This does seem strange.
Is there some technical limitation?

It would be much more useful if text type select fields could also use this module.
Working for integer fields only greatly reduces the usefulness of this module.

john franklin’s picture

The code that denies non-numeric keyed forms was in response to #362746: Check that #options are valid, else abort conversion to checkboxes. It looks like it was applied broadly to fix a critical incompatibility with the intention of refining the patch later.

For those interested, the commit in question is d063a1fc.