mirror of
https://github.com/processwire/processwire.git
synced 2025-08-16 11:44:42 +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);
|
reset($options);
|
||||||
$key = key($options);
|
$key = key($options);
|
||||||
$hasBlankOption = empty($key);
|
$hasBlankOption = empty($key);
|
||||||
if($allowBlank && !$hasBlankOption && !$this->attr('multiple')
|
if($allowBlank && !$hasBlankOption && !$this->attr('multiple')) {
|
||||||
&& (!$this->required || ($this->hasFieldtype == 'FieldtypeOptions' && !$this->attr('value')))) {
|
if($this->getSetting('required') && $this->attr('value')) {
|
||||||
$out .= "<option value=''> </option>";
|
// if required and a value is already selected, do not add a blank option
|
||||||
|
} else {
|
||||||
|
$out .= "<option value=''> </option>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($options as $value => $label) {
|
foreach($options as $value => $label) {
|
||||||
|
Reference in New Issue
Block a user