Permalink
Browse files

Merge branch 'hotfix/3792' into develop

Close #3792
  • Loading branch information...
2 parents 63e4aef + 4597759 commit de793baa340a13d038351434f9d8b5a7532df637 @weierophinney weierophinney committed Feb 19, 2013
View
5 library/Zend/Form/View/Helper/FormSelect.php
@@ -160,6 +160,11 @@ public function renderOptions(array $options, array $selectedOptions = array())
}
$attributes = compact('value', 'selected', 'disabled');
+
+ if (isset($optionSpec['attributes']) && is_array($optionSpec['attributes'])) {
+ $attributes = array_merge($attributes, $optionSpec['attributes']);
+ }
+
$this->validTagAttributes = $this->validOptionAttributes;
$optionStrings[] = sprintf(
$template,
View
6 tests/ZendTest/Form/View/Helper/FormSelectTest.php
@@ -37,6 +37,9 @@ public function getElement()
array(
'label' => 'This is the third label',
'value' => 'value3',
+ 'attributes' => array(
+ 'class' => 'test-class',
+ ),
),
);
$element->setValueOptions($options);
@@ -58,6 +61,9 @@ public function testCreatesSelectWithOptionsFromAttribute()
$this->assertContains('value="value1"', $markup);
$this->assertContains('value="value2"', $markup);
$this->assertContains('value="value3"', $markup);
+
+ //Test class attribute on third option
+ $this->assertRegexp('#option .*?value="value3" class="test-class"#', $markup);
}
public function testCanMarkSingleOptionAsSelected()

0 comments on commit de793ba

Please sign in to comment.