From 7458d0504c10e50068df845ebd60ca9a9104fa47 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 10 May 2018 06:02:57 -0400 Subject: [PATCH] Make InputfieldSelect show blank option even when selection is required per processwire/processwire-issues#585 --- wire/modules/Inputfield/InputfieldSelect.module | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wire/modules/Inputfield/InputfieldSelect.module b/wire/modules/Inputfield/InputfieldSelect.module index 9358f88b..8c2d6c8a 100644 --- a/wire/modules/Inputfield/InputfieldSelect.module +++ b/wire/modules/Inputfield/InputfieldSelect.module @@ -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 .= ""; + 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 .= ""; + } } foreach($options as $value => $label) {