0

我想知道如何删除所有形成 zend 框架 2 自动添加的 HTML?

我希望每个输入的结果是这样的:

<label for="email" class="required"> Email </ label>
<input type="text" name="email" id="email" value="" class="span5">

而不是这个:

<label>
<span> Email </ span>
<input type="text" name="email" class="span5" value="">
</ label>

我能怎么做?

4

1 回答 1

1

检查表单渲染http://framework.zend.com/manual/2.0/en/modules/zend.form.quick-start.html#rendering

你可以像这样平滑:

// set the needed atributes
$email = new Element\Email('email');
$email->setLabel('Contact Email')
 ->setAttribute('title', 'Please enter your email address')
->setAttribute('id', 'email')
->setAttribute('value', 'Email')
->setAttribute("onfocus", 'if(this.value==\'Email\')this.value=\'\'')
->setAttribute('onblur', 'if(this.value==\'\')this.value=\'Email\'');

// this for rendering in your phtml file
$email = $form->get('emali');
echo $formLabel->openTag() . $name->getOption('label');
echo $formLabel->closeTag();
echo $this->formInput($name);
echo $this->formElementErrors($name);
于 2013-06-26T11:39:56.870 回答