Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix/form label options #5226

Merged
merged 3 commits into from

4 participants

@dpommeranz

The recently added label option "disable_html_escape" (#4677) should also work for multi option elements.

@texdc

Good catch! Can you provide a test?

@froschdesign
public function testDisableEscapeHtmlHelper()
{
    $element = new MultiCheckboxElement('foo');
    $element->setLabelOptions(
        array(
             'disable_html_escape' => true,
        )
    );
    $element->setValueOptions(
        array(
             array(
                 'label' => '<span>label1</span>',
                 'value' => 'value1',
             ),
        )
    );

    $this->assertEquals(
        '<label><input type="checkbox" name="foo[]" value="value1"><span>label1</span></label>',
        $this->helper->render($element)
    );
}
@dpommeranz

test added. thanks @froschdesign

@weierophinney weierophinney merged commit 1384674 into zendframework:develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
5 library/Zend/Form/View/Helper/FormMultiCheckbox.php
@@ -148,6 +148,7 @@ protected function renderOptions(MultiCheckboxElement $element, array $options,
array $attributes)
{
$escapeHtmlHelper = $this->getEscapeHtmlHelper();
+ $labelOptions = $element->getLabelOptions();
$labelHelper = $this->getLabelHelper();
$labelClose = $labelHelper->closeTag();
$labelPosition = $this->getLabelPosition();
@@ -222,7 +223,9 @@ protected function renderOptions(MultiCheckboxElement $element, array $options,
);
}
- $label = $escapeHtmlHelper($label);
+ if (empty($labelOptions) || $labelOptions['disable_html_escape'] == false) {
+ $label = $escapeHtmlHelper($label);
+ }
$labelOpen = $labelHelper->openTag($labelAttributes);
$template = $labelOpen . '%s%s' . $labelClose;
switch ($labelPosition) {
View
16 tests/ZendTest/Form/View/Helper/FormMultiCheckboxTest.php
@@ -402,4 +402,20 @@ public function testGetSelectedAttributeForGroupReturnTrue()
$this->assertRegexp('#value="value1" checked="checked"#', $markup);
}
+
+ public function testDisableEscapeHtmlHelper()
+ {
+ $element = new MultiCheckboxElement('foo');
+ $element->setLabelOptions(array(
+ 'disable_html_escape' => true,
+ ));
+ $element->setValueOptions(array(
+ array(
+ 'label' => '<span>label1</span>',
+ 'value' => 'value1',
+ ),
+ ));
+ $markup = $this->helper->render($element);
+ $this->assertRegexp('#<span>label1</span>#', $markup);
+ }
}
Something went wrong with that request. Please try again.