From 4b602add0567bc32b36762f2cf7e9ec1428e999d Mon Sep 17 00:00:00 2001 From: Victor Seager Date: Thu, 25 Oct 2012 22:12:23 +0200 Subject: [PATCH 1/4] Add empty option before empty check --- library/Zend/Form/View/Helper/FormSelect.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/Zend/Form/View/Helper/FormSelect.php b/library/Zend/Form/View/Helper/FormSelect.php index dcd9eea6616..cc420fda53b 100644 --- a/library/Zend/Form/View/Helper/FormSelect.php +++ b/library/Zend/Form/View/Helper/FormSelect.php @@ -78,6 +78,11 @@ public function render(ElementInterface $element) } $options = $element->getValueOptions(); + + if (($emptyOption = $element->getEmptyOption()) !== null) { + $options = array('' => $emptyOption) + $options; + } + if (empty($options)) { throw new Exception\DomainException(sprintf( '%s requires that the element has "value_options"; none found', @@ -85,10 +90,6 @@ public function render(ElementInterface $element) )); } - if (($emptyOption = $element->getEmptyOption()) !== null) { - $options = array('' => $emptyOption) + $options; - } - $attributes = $element->getAttributes(); $value = $this->validateMultiValue($element->getValue(), $attributes); From 474f894c5a0f00af75b35bf468f2eecd3cee6910 Mon Sep 17 00:00:00 2001 From: Victor Seager Date: Thu, 25 Oct 2012 22:32:39 +0200 Subject: [PATCH 2/4] Removed check for empty option --- library/Zend/Form/View/Helper/FormSelect.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/library/Zend/Form/View/Helper/FormSelect.php b/library/Zend/Form/View/Helper/FormSelect.php index cc420fda53b..88ea28f4233 100644 --- a/library/Zend/Form/View/Helper/FormSelect.php +++ b/library/Zend/Form/View/Helper/FormSelect.php @@ -83,13 +83,6 @@ public function render(ElementInterface $element) $options = array('' => $emptyOption) + $options; } - if (empty($options)) { - throw new Exception\DomainException(sprintf( - '%s requires that the element has "value_options"; none found', - __METHOD__ - )); - } - $attributes = $element->getAttributes(); $value = $this->validateMultiValue($element->getValue(), $attributes); From 8e22b3c6430ba21650886fa44a9f0f35a2b29d20 Mon Sep 17 00:00:00 2001 From: Victor Seager Date: Wed, 31 Oct 2012 09:48:49 +0000 Subject: [PATCH 3/4] Updated test for PR#2837 --- tests/ZendTest/Form/View/Helper/FormSelectTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/ZendTest/Form/View/Helper/FormSelectTest.php b/tests/ZendTest/Form/View/Helper/FormSelectTest.php index 0f7426fdbda..ea3754c60eb 100644 --- a/tests/ZendTest/Form/View/Helper/FormSelectTest.php +++ b/tests/ZendTest/Form/View/Helper/FormSelectTest.php @@ -337,11 +337,9 @@ public function testRenderElementWithNoNameRaisesException() $this->helper->render($element); } - public function testRenderElementWithNoValueOptionsRaisesException() + public function testRenderElementWithNoValueOptionsDoesNotRaiseException() { $element = new SelectElement('foo'); - - $this->setExpectedException('Zend\Form\Exception\DomainException'); $this->helper->render($element); } } From b98d1af9c65c5c0f515b7146b21d849106716eda Mon Sep 17 00:00:00 2001 From: Victor Seager Date: Wed, 7 Nov 2012 14:43:34 +0000 Subject: [PATCH 4/4] Removed test for PR#2837 --- tests/ZendTest/Form/View/Helper/FormSelectTest.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/ZendTest/Form/View/Helper/FormSelectTest.php b/tests/ZendTest/Form/View/Helper/FormSelectTest.php index ea3754c60eb..4a5fe800f0f 100644 --- a/tests/ZendTest/Form/View/Helper/FormSelectTest.php +++ b/tests/ZendTest/Form/View/Helper/FormSelectTest.php @@ -336,10 +336,4 @@ public function testRenderElementWithNoNameRaisesException() $this->setExpectedException('Zend\Form\Exception\DomainException'); $this->helper->render($element); } - - public function testRenderElementWithNoValueOptionsDoesNotRaiseException() - { - $element = new SelectElement('foo'); - $this->helper->render($element); - } }