There seems to be a little bug in Zenf_Form, as it uses
<br />
even for HTML doctype in a specific case.
This is how you can reproduce the error:
Create a form like this:
<?php
class Settings extends Zend_Form
{
public function init()
{
$this->setMethod('post');
$this->setAttrib('class', 'settings-form');
$video_quality = new Zend_Form_Element_Radio('video_quality', array(
'label' => 'Video quality',
'required' => true,
'class' => 'input-radio',
'multiOptions' => array(
'1' => 'High (Minimum download bandwidth is 2 Mb/s)',
'2' => 'Low (Minimum download bandwidth is 0.5 Mb/s)',
)
));
$submit = new Zend_Form_Element_Submit('save_settings', array(
'label' => 'Uložiť',
'class' => 'input-submit'
));
$this->addElements(array(
$video_quality,
$submit
));
}
}
Set your doctype to:
$view->doctype('HTML4_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type',
'text/html; charset=UTF-8');
And echo the form. This will be the output:
<form enctype="application/x-www-form-urlencoded" method="post" class="settings-form" action="/clientarea/index/settings"><dl class="zend_form">
<dt id="video_quality-label"><label class="required">Video quality</label></dt>
<dd id="video_quality-element">
<label for="video_quality-1"><input type="radio" name="video_quality" id="video_quality-1" value="1" class="input-radio">High (Minimum download bandwidth is 2 Mb/s)</label><br /><label for="video_quality-2"><input type="radio" name="video_qual开发者_StackOverflow社区ity" id="video_quality-2" value="2" checked="checked" class="input-radio">Low (Minimum download bandwidth is 0.5 Mb/s)</label></dd>
<dt id="save_settings-label"> </dt><dd id="save_settings-element">
<input type="submit" name="save_settings" id="save_settings" value="Save" class="input-submit"></dd></dl></form>
Notice the
<br />
tag there. It should just be
<br>
I think it's actually a bug, but you could override the default separator it uses, like so:
$video_quality = new Zend_Form_Element_Radio('video_quality', array(
'label' => 'Video quality',
'required' => true,
'separator' => '<br>', // here is the new separator
'class' => 'input-radio',
'multiOptions' => array(
'1' => 'High (Minimum download bandwidth is 2 Mb/s)',
'2' => 'Low (Minimum download bandwidth is 0.5 Mb/s)',
)
));
or:
$video_quality->setSeparator( '<br>' );
精彩评论