Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add empty option before empty check #2837

Closed
wants to merge 4 commits into from

5 participants

@vseager

Add empty option to options array before checking if is empty, to allow for an empty select in cases where a user may not have added options into database require to populate field.

@davidwindell

:thumbsup: this would save us a lot of code checks

@davidwindell

Actually, I'd prefer if it didn't throw a hard exception at all, I don't see the need for it here as the validator would check for an empty value. Can you update the PR?

@weierophinney

Please update the tests as well, as they are testing for an exception thrown when no options are passed, and thus failing.

@minlare

I have a select which will be populated by javascript. Please can we get this merged asap.

tests/ZendTest/Form/View/Helper/FormSelectTest.php
@@ -337,11 +337,9 @@ public function testRenderElementWithNoNameRaisesException()
$this->helper->render($element);
}
- public function testRenderElementWithNoValueOptionsRaisesException()
+ public function testRenderElementWithNoValueOptionsDoesNotRaiseException()
@Maks3w Collaborator
Maks3w added a note

In fact the test should be removed due the almost the test of the file already test this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@davidwindell

@Maks3w doesn't this serve as a regression test?

@Maks3w
Collaborator

@davidwindell Do a regression with this is really very very hard, it's not as simple as change a conditional operator or something. This involve throw an exception.

@davidwindell

@vseager can you remove the test?

@vseager vseager closed this
@vseager vseager reopened this
@vseager

@weierophinney Travis is failing on PHP 5.3.3 but not on newer versions. Can you pass this PR?

@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/2837'
Close #2837
6acf145
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/2837' into develop
Forward port #2837
e6d6368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 25, 2012
  1. @vseager
  2. @vseager
Commits on Oct 31, 2012
  1. @vseager

    Updated test for PR#2837

    vseager authored
Commits on Nov 7, 2012
  1. @vseager

    Removed test for PR#2837

    vseager authored
This page is out of date. Refresh to see the latest.
View
6 library/Zend/Form/View/Helper/FormSelect.php
@@ -78,12 +78,6 @@ public function render(ElementInterface $element)
}
$options = $element->getValueOptions();
- if (empty($options)) {
- throw new Exception\DomainException(sprintf(
- '%s requires that the element has "value_options"; none found',
- __METHOD__
- ));
- }
if (($emptyOption = $element->getEmptyOption()) !== null) {
$options = array('' => $emptyOption) + $options;
View
8 tests/ZendTest/Form/View/Helper/FormSelectTest.php
@@ -336,12 +336,4 @@ public function testRenderElementWithNoNameRaisesException()
$this->setExpectedException('Zend\Form\Exception\DomainException');
$this->helper->render($element);
}
-
- public function testRenderElementWithNoValueOptionsRaisesException()
- {
- $element = new SelectElement('foo');
-
- $this->setExpectedException('Zend\Form\Exception\DomainException');
- $this->helper->render($element);
- }
}
Something went wrong with that request. Please try again.