mirror of
https://github.com/processwire/processwire.git
synced 2025-08-15 19:24:28 +02:00
Make InputfieldSelect show blank option even when selection is required per processwire/processwire-issues#585
This commit is contained in:
@@ -276,9 +276,12 @@ class InputfieldSelect extends Inputfield {
|
||||
reset($options);
|
||||
$key = key($options);
|
||||
$hasBlankOption = empty($key);
|
||||
if($allowBlank && !$hasBlankOption && !$this->attr('multiple')
|
||||
&& (!$this->required || ($this->hasFieldtype == 'FieldtypeOptions' && !$this->attr('value')))) {
|
||||
$out .= "<option value=''> </option>";
|
||||
if($allowBlank && !$hasBlankOption && !$this->attr('multiple')) {
|
||||
if($this->getSetting('required') && $this->attr('value')) {
|
||||
// if required and a value is already selected, do not add a blank option
|
||||
} else {
|
||||
$out .= "<option value=''> </option>";
|
||||
}
|
||||
}
|
||||
|
||||
foreach($options as $value => $label) {
|
||||
|
Reference in New Issue
Block a user