Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'options-attributes' of git://github.com/neilime/zf2 int…
Browse files Browse the repository at this point in the history
…o hotfix/3792
  • Loading branch information
weierophinney committed Feb 19, 2013
2 parents 63e4aef + 741881d commit 4597759
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/Zend/Form/View/Helper/FormSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/ZendTest/Form/View/Helper/FormSelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function getElement()
array(
'label' => 'This is the third label',
'value' => 'value3',
'attributes' => array(
'class' => 'test-class',
),
),
);
$element->setValueOptions($options);
Expand All @@ -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()
Expand Down

0 comments on commit 4597759

Please sign in to comment.