Skip to content

Commit 689789e

Browse files
authored
fix: add default value for dropdown to avoid empty dropdown (#915)
* fix: add default value for dropdown to avoid empty dropdown * Update CHANGELOG.md * fix multiple input error * update CHANGELOG.md
1 parent 3a78be8 commit 689789e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
## [UNRELAESE]
99

1010
- Fix container update from `API`
11+
- Fix: fix default value for `dropdown` field to avoid empty dropdown
1112

1213
## [1.21.18] - 2024-01-16
1314

ajax/field_specific_fields.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,17 @@ function ($itemtype) {
119119
if ($field->isNewItem() && $type == 'dropdown') {
120120
echo '<em class="form-control-plaintext">';
121121
echo __s('Default value will be configurable once field will be created.', 'fields');
122+
if (!$multiple) {
123+
echo '<input type="hidden" name="default_value" value="" />';
124+
}
122125
echo '</em>';
123126
} else {
124127
$itemtype = $type == 'dropdown'
125128
? PluginFieldsDropdown::getClassname($field->fields['name'])
126129
: $dropdown_matches['class'];
130+
if ($field->fields['default_value'] === null) {
131+
$field->fields['default_value'] = '';
132+
}
127133
$default_value = $multiple ? json_decode($field->fields['default_value']) : $field->fields['default_value'];
128134
Dropdown::show(
129135
$itemtype,

0 commit comments

Comments
 (0)