Other options will be never added permanently to the list of options using a multiselect widget (it works nice for single select).

Have a look at following code fragment:

 if (
      $element['select']['#value'] == 'select_or_other' &&
      !empty($element['other']['#value']) &&
      !isset($element['#options'][$element['other']['#value']])
    ) { ...

The first condition isn't fulfilled using multiselect widgets (it contains an array with key and value 'select_or_other' instead of a string 'select_or_other'). Perhaps we can simply add a condition for multiselect checking for key:

 if (
      ($element['select']['#value'] == 'select_or_other' || isset($element['select']['#value']['select_or_other'])) &&
      !empty($element['other']['#value']) &&
      !isset($element['#options'][$element['other']['#value']])
    ) { ...

For me, it works, but I'm not sure if this change is useful?

Comments

danielb’s picture

Status: Active » Fixed

cheers I changed it to

      ($element['select']['#value'] == 'select_or_other' || in_array('select_or_other', $element['select']['#value'])) &&

more consistent with the way it's done elsewhere
thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

danielb’s picture

-

  • Commit ab10280 on 7.x-2.x, 7.x-3.x, 8.x-3.x by danielb:
    Issue #1596430 by Helmut Neubauer, danielb: Append to values with...