Zend 2.0 with Smarty:在.tpl文件上显示Zend Form

时间:2015-09-26 09:06:16

标签: php zend-framework2 smarty zend-form

我在Zend 2.0中遇到了麻烦。 我做了一个教程:https://packages.zendframework.com/docs/latest/manual/en/user-guide/skeleton-application.html 然后我通过以下方式实施了Smarty:How can Smarty 3 be Used with Zend Framework 2? 在.phtml中显示表单Zend_From看起来像这样:

$form = $this->form;
$form->setAttribute('action', $this->url('album', array('action' => 'add')));
$form->prepare();
echo $this->form()->openTag($form);
echo $this->formHidden($form->get('id'));
echo $this->formRow($form->get('title'));
echo $this->formRow($form->get('artist'));
echo $this->formSubmit($form->get('submit'));
echo $this->form()->closeTag();

但是如何显示$this->form我的Smarty模板?

1 个答案:

答案 0 :(得分:0)

解决方案是:

{assign var="form" value=$this->form}
{assign var="attr" value=$form->setAttribute('action', $this->url('album', ['action' => 'add']))}
{assign var="prep" value=$form->prepare()}
{$this->form()->openTag($this->form)}
{$this->formCollection($this->form)}
{$this->form()->closeTag()}