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

Commit

Permalink
Merge branch 'hotfix/form-multicheckbox' into releases/2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Aug 30, 2012
2 parents 4ce1f7e + bd8f89b commit ff0927a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -17,6 +17,8 @@ XX August 2012
- Zend\Di
- Fixes ArrayDefinition and ClassDefinition hasMethods() methods to return
boolean values.
- Zend\Form
- Fixes issue with multi-checkbox rendering.
- Zend\Ldap
- Fixes an error nesting condition
- Zend\Log
Expand Down
9 changes: 9 additions & 0 deletions library/Zend/Form/Element/MultiCheckbox.php
Expand Up @@ -21,6 +21,15 @@
*/
class MultiCheckbox extends Checkbox
{
/**
* Seed attributes
*
* @var array
*/
protected $attributes = array(
'type' => 'multi_checkbox',
);

/**
* @var bool
*/
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Form/View/Helper/FormRow.php
Expand Up @@ -99,7 +99,7 @@ public function render(ElementInterface $element)
// Multicheckbox elements have to be handled differently as the HTML standard does not allow nested
// labels. The semantic way is to group them inside a fieldset
$type = $element->getAttribute('type');
if ($type === 'multi_checkbox' || $type === 'multicheckbox' || $type === 'radio') {
if ($type === 'multi_checkbox' || $type === 'radio') {
$markup = sprintf(
'<fieldset><legend>%s</legend>%s</fieldset>',
$label,
Expand Down
9 changes: 9 additions & 0 deletions tests/ZendTest/Form/Element/MultiCheckboxTest.php
Expand Up @@ -104,4 +104,13 @@ public function testInArrayValidationOfOptions($valueTests, $options)
$this->assertInstanceOf('Zend\Validator\Explode', $explodeValidator);
$this->assertTrue($explodeValidator->isValid($valueTests));
}

public function testAttributeType()
{
$element = new MultiCheckboxElement();
$attributes = $element->getAttributes();

$this->assertArrayHasKey('type', $attributes);
$this->assertEquals('multi_checkbox', $attributes['type']);
}
}
3 changes: 3 additions & 0 deletions tests/ZendTest/Form/View/Helper/FormElementTest.php
Expand Up @@ -112,10 +112,13 @@ public function testRendersMultiElementsAsExpected($type, $inputType, $additiona
{
if ($type === 'radio') {
$element = new Element\Radio('foo');
$this->assertEquals('radio', $element->getAttribute('type'));
} elseif ($type === 'multi_checkbox') {
$element = new Element\MultiCheckbox('foo');
$this->assertEquals('multi_checkbox', $element->getAttribute('type'));
} elseif ($type === 'select') {
$element = new Element\Select('foo');
$this->assertEquals('select', $element->getAttribute('type'));
} else {
$element = new Element('foo');
}
Expand Down

0 comments on commit ff0927a

Please sign in to comment.