'#empty_value', '#empty_option' does not work properly

Created on 17 September 2020, over 4 years ago
Updated 7 May 2024, 8 months ago

Code example that is not rendered as expected:

$form['name'] = array(
  '#type' => 'select2',
  '#title' => 'Some title',
  '#options' => [1 => 'One', 2 => 'Two'],
  '#empty_option' => '[custom empty value]',
  '#empty_value' => -1,
);

Result: https://prnt.sc/Fb3w9Ed-pFVk
There is an item with empty string added to dropdown (expected to have '#empty_option' property value as a content).

Code in Merge Request checks if '#empty_option' property is set and uses it as content for such empty option element.

Thank you!

πŸ› Bug report
Status

RTBC

Version

1.0

Component

User interface

Created by

πŸ‡§πŸ‡ΎBelarus f1mishutka Minsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024