From d5356fa7de2b98cbb93f8f28b0f3ecc7d51b8b0f Mon Sep 17 00:00:00 2001 From: sunhao Date: Thu, 11 May 2023 11:47:35 +0800 Subject: [PATCH] * zin: remove prop "optional", prepend empty item when required is false. --- lib/zin/wg/select/v1.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/zin/wg/select/v1.php b/lib/zin/wg/select/v1.php index cda6e30367..d4b7fb6d8f 100644 --- a/lib/zin/wg/select/v1.php +++ b/lib/zin/wg/select/v1.php @@ -34,7 +34,6 @@ class select extends wg 'required?: bool', 'disabled?: bool', 'multiple?: bool', - 'optional?: bool', 'items?: array', 'size?: int', ); @@ -97,7 +96,7 @@ class select extends wg */ protected function build() { - list($items, $multiple, $required, $optional) = $this->prop(array('items', 'multiple', 'required', 'optional')); + list($items, $multiple, $required) = $this->prop(array('items', 'multiple', 'required')); $hasEmptyItem = false; $valueList = $this->getValueList(); @@ -114,10 +113,10 @@ class select extends wg } } - /* Prepend empty option when current optional select has no empty item. */ - if($optional && !$hasEmptyItem) array_unshift($items, $this->onBuildItem(array('text' => '', 'value' => '', 'selected' => in_array('', $valueList)))); + /* Prepend empty option when current select is not required and whitout any empty item. */ + if(!$required && !$hasEmptyItem) array_unshift($items, $this->onBuildItem(array('text' => '', 'value' => '', 'selected' => in_array('', $valueList)))); - $props = $this->props->skip(['items', 'value', 'multiple', 'required', 'optional']); + $props = $this->props->skip(['items', 'value', 'multiple', 'required']); return h::select (