hafizi
March 5, 2020, 1:49am
1
I always get an empty option in the select field types, even though I defined a default option and add correct field types ‘select’. need suggestion and help how to solve this,
{
“options”: “Live, Under Maintenance”,
“default”: “Live”
}
Hi @hafizi ,
Did you solve your problem with your empty option ?
I tried this solution but it doesn’t work for me…
abernh
September 17, 2021, 2:47pm
3
Currently there is always an empty option rendered with the other select options
<field-select>
<div if="{loading}"><i class="uk-icon-spinner uk-icon-spin"></i></div>
<select ref="input" class="uk-width-1-1 {opts.cls}" bind="{ opts.bind }" show="{!loading}" multiple="{opts.multiple}">
<option value=""></option>
<optgroup each="{group in Object.keys(groups).sort()}" label="{group}">
<option each="{ option,idx in parent.groups[group] }" value="{ option.value }" selected="{ isSelected(option.value) }">{ option.label }</option>
</optgroup>
<option each="{ option,idx in options }" value="{ option.value }" selected="{ isSelected(option.value) }">{ option.label }</option>
</select>
<script>
var $this = this;
You could create a JS script, that is loaded after rendering and removing the first empty option.
Or use a CSS block.
// config/bootstrap.php
$app->on('collections.entry.aside', function ($collectionName) {
echo "
<style>
select[bind^=\"entry\"] > option[value=\"\"]:first-child{ display: none; }
</style>
";
});
Thanks abernh,
I’ll do that!!!