0

我需要在 Zend 框架中设置我的复选框的样式,此时我的 zend 表单会像这样填充标签:

<dt id="disabled-label"><label for="disabled" class="optional">Disabled Access</label></dt>
<dd id="disabled-element">
<input type="hidden" name="disabled" value="0"><input type="checkbox" name="disabled" id="disabled" value="1"></dd>

我需要它输出:

残疾人通道

下面是目前的 zend 形式,显然我只给出了上面 HTML 的较短版本:

    public function searchForm() {
        $sp = $this->createElement('checkbox', 'sw')
                ->setOptions(
                array(
                    'label' => 'Swimming Pool',
                )
        );

        $spa = $this->createElement('checkbox', 'spa')
                ->setOptions(
                array(
                    'label' => 'Spa ',
                )
        );

        $gym = $this->createElement('checkbox', 'gym')
                ->setOptions(
                array(
                    'label' => 'Gym ',
                )
        );

        $wifi = $this->createElement('checkbox', 'wifi')
                ->setOptions(
                array(
                    'label' => 'Wifi ',
                )
        );

        $parking = $this->createElement('checkbox', 'parking')
                ->setOptions(
                array(
                    'label' => 'On-Site Parking ',
                )
        );

        $golf = $this->createElement('checkbox', 'golf')
                ->setOptions(
                array(
                    'label' => 'Golf ',
                )
        );

        $wp = $this->createElement('checkbox', 'wp')
                ->setOptions(
                array(
                    'label' => 'Wedding Packages ',
                )
        );

        $cc = $this->createElement('checkbox', 'cc')
                ->setOptions(
                array(
                    'label' => 'Civil Ceremonies ',
                )
        );

        $city = $this->createElement('checkbox', 'city')
                ->setOptions(
                array(
                    'label' => 'City Central ',
                )
        );

        $oot = $this->createElement('checkbox', 'oot')
                ->setOptions(
                array(
                    'label' => 'Out Of Town ',
                )
        );

        $disabled = $this->createElement('checkbox', 'disabled')
                ->setOptions(
                array(
                    'label' => 'Disabled Access ',
                )
        );

        $submit = $this->createElement('submit', 'submit')
                                ->setOptions
                                (array('label' => 'SEARCH OUR HOTELS',
                                       'class' => 'f-left btn-purple icon'
                                    ));

        $this->addElement($sp)
                ->addElement($spa)
                ->addElement($gym)
                ->addElement($wifi)
                ->addElement($parking)
                ->addElement($golf)
                ->addElement($wp)
                ->addElement($cc)
                ->addElement($city)
                ->addElement($oot)
                ->addElement($disabled)
                ->addElement($submit);
    }

}
4

2 回答 2

0

您可以使用以下方法删除dtddWrapper装饰器:

$element->removeDecorator('DtDdWrapper');

但它仍然会添加<label for...>标签。

或者您可以添加自己的装饰器...有关详细信息,请参阅此帖子

于 2013-10-24T16:31:16.753 回答
0

利用:->setLabelAttributes(array(''))

于 2013-10-24T16:37:04.357 回答