您好,我正在尝试在 viewscript 中包含一个表单,但我做不到,我不知道为什么,但是 viewscript 看不到我的表单。在控制器中我有这个:
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Authentication\AuthenticationService;
use MyAuth\Form\LoginForm;
class IndexController extends AbstractActionController
{
public function indexAction()
{
error_log("executing:".__METHOD__);
$this->view = new ViewModel();
$form = new LoginForm();
if(isset($this->view)){
error_log("view exists in ".__METHOD__);
}
$this->view->form = $form;
}
}
和视图:
<div class="hero-unit">
<h1><?php echo sprintf($this->translate('Welcome to %sZend Framework 2%s'), '<span class="zf-green">', '</span>') ?></h1>
<p><?php echo sprintf($this->translate('Congratulations! You have successfully installed the %sZF2 Skeleton Application%s. You are currently running Zend Framework version %s. This skeleton can serve as a simple starting point for you to begin building your application on ZF2.'), '<a href="https://github.com/zendframework/ZendSkeletonApplication" target="_blank">', '</a>', \Zend\Version\Version::VERSION) ?></p>
<p><a class="btn btn-success btn-large" href="https://github.com/zendframework/zf2" target="_blank"><?php echo $this->translate('Fork Zend Framework 2 on GitHub') ?> »</a></p>
</div>
<div class="row">
<?php
if(isset($this->form))
{
error_log("form exists in ViewScript");
}else{
error_log("form does not exists");
}
?>
<div class="span4">
<h2><?php echo $this->translate('Follow Development') ?></h2>
<p><?php echo sprintf($this->translate('Zend Framework 2 is under active development. If you are interested in following the development of ZF2, there is a special ZF2 portal on the official Zend Framework website which provides links to the ZF2 %swiki%s, %sdev blog%s, %sissue tracker%s, and much more. This is a great resource for staying up to date with the latest developments!'), '<a href="http://framework.zend.com/wiki/display/ZFDEV2/Home">', '</a>', '<a href="http://framework.zend.com/zf2/blog">', '</a>', '<a href="http://framework.zend.com/issues/browse/ZF2">', '</a>') ?></p>
<p><a class="btn btn-success" href="http://framework.zend.com/zf2" target="_blank"><?php echo $this->translate('ZF2 Development Portal') ?> »</a></p>
</div>
怎么了?我已经 2 天试图解决它,但我无法解决它谢谢