From 2014f7fdeb64fe7dd681bf6f5746c40be875ca71 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Wed, 29 Jan 2020 16:14:23 -0500 Subject: [PATCH] - UiInput and UiSelect now allows NULL values to be passed --- src/Form/UiInput.php | 3 ++- src/Form/UiSelect.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Form/UiInput.php b/src/Form/UiInput.php index 1490b15..0497fbb 100644 --- a/src/Form/UiInput.php +++ b/src/Form/UiInput.php @@ -22,10 +22,11 @@ class UiInput extends UiElement implements Extension { return "buildHtml($arguments) ?>"; } - public function buildHtml(string $name, string $value, array $attributes = []) : string + public function buildHtml(string $name, ? string $value = null, array $attributes = []) : string { $this->setValue($value); $this->attributes([ 'name' => $name ] + $attributes + $this->attributes); + return $this->render(); } diff --git a/src/Form/UiSelect.php b/src/Form/UiSelect.php index 597251f..0fb92b5 100644 --- a/src/Form/UiSelect.php +++ b/src/Form/UiSelect.php @@ -22,7 +22,7 @@ class UiSelect extends UiElement implements Extension { return "buildHtml($arguments) ?>"; } - public function buildHtml(string $name, array $list, $value, array $attributes = [], bool $strictComparison = true) : string + public function buildHtml(string $name, array $list, $value = null, array $attributes = [], bool $strictComparison = true) : string { $this->attributes([ 'name' => $name ] + $attributes + $this->attributes); $this->setList($list, $value, $strictComparison); @@ -40,6 +40,7 @@ class UiSelect extends UiElement implements Extension { foreach($list as $key => $item) { if ($item instanceof UiElement) { $this->append($item); + continue; } elseif ( is_array($item) ) { $obj = new UiElement("optgroup");