目前,我使用这个:
<?php echo $this->form()->openTag($form); ?>
<?php echo $this->formHidden($form->get('page_id')); ?>
<fieldset>
<?php echo $this->formRow($form->get('title')); ?>
</fieldset>
<fieldset>
<?php echo $this->formRow($form->get('content')); ?>
</fieldset>
<fieldset>
<?php echo $this->formRow($form->get('url_slug')); ?>
</fieldset>
<fieldset>
<?php echo $this->formSubmit($form->get('submit')); ?>
</fieldset>
<?php echo $this->form()->closeTag(); ?>
在视图脚本中显示我的表单,但我想添加一些额外的样式、html 属性等,所以最好用纯 html 编写表单。到目前为止一切顺利,但是否可以在不使用上述方法的情况下在 html 视图中显示表单错误?在 ZF1 中,我使用了:
<ul>
<?php foreach ($this->form->class->getMessages() as $key => $value): ?>
<li><?php echo $value; ?></li>
<?php endforeach; ?>
<?php foreach ($this->form->letter->getMessages() as $key => $value): ?>
<li><?php echo $value; ?></li>
<?php endforeach; ?>
<?php foreach ($this->form->type->getMessages() as $key => $value): ?>
<li><?php echo $value; ?></li>
<?php endforeach; ?>
</ul>
//the html of the form
任何帮助深表感谢。提前致谢。:)