1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-16 03:34:33 +02:00

Make InputfieldSelect show blank option even when selection is required per processwire/processwire-issues#585

This commit is contained in:
Ryan Cramer
2018-05-10 06:02:57 -04:00
parent 04123e305a
commit 7458d0504c

View File

@@ -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=''>&nbsp;</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=''>&nbsp;</option>";
}
}
foreach($options as $value => $label) {