TypeError: array_values(): Argument #1 ($array) must be of type array in processSelectTagify() when #multiple is TRUE and no #default_value is set
### Problem/Motivation Any form with a `select_tagify` element that sets `#multiple => TRUE` but no `#default_value` crashes on the initial form build: ``` TypeError: array_values(): Argument #1 ($array) must be of type array, string given in Drupal\tagify\Element\SelectTagify::processSelectTagify() (line 157 of modules/contrib/tagify/src/Element/SelectTagify.php) ``` Root cause chain: 1. On the initial build there is no input for the element, so `FormBuilder::handleInputElement()` calls `Select::valueCallback()` with `$input === FALSE`. Core's `Select::valueCallback()` only handles the `$input !== FALSE` case and returns `NULL`. 2. `FormBuilder` then falls back to `$element['#value'] = $element['#default_value'] ?? '';` (core `FormBuilder.php`). With no `#default_value`, `#value` becomes the string `''`. 3. `processSelectTagify()` then runs the selection-order sorting block introduced in #3352158: ```php if ($element['#multiple']) { $selected_values = array_values($element['#value']); ``` `array_values('')` throws a `TypeError` on PHP 8+. A plain core `select` element handles the `''` value fine; the crash is specific to this sorting block. Related but distinct: #3577529 describes a `#multiple` selection problem in custom forms where a `#default_value` *is* set (so this crash does not trigger). ### Steps to reproduce Add this to any custom form and visit it: ```php $form['tags'] = [ '#type' => 'select_tagify', '#multiple' => TRUE, '#options' => ['a' => 'A', 'b' => 'B'], ]; ``` White screen with the `TypeError` above. Workaround: always pass `'#default_value' => []`. ### Proposed resolution Guard the sorting block so it only runs when `#value` is an array — with nothing selected there is nothing to sort: ```php if ($element['#multiple'] && is_array($element['#value'] ?? NULL)) { ```
issue