Skip to content

Instantly share code, notes, and snippets.

@grizzm0
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grizzm0/5a2dfe91f37a20c1f68a to your computer and use it in GitHub Desktop.
Save grizzm0/5a2dfe91f37a20c1f68a to your computer and use it in GitHub Desktop.
<?php
namespace Module\View\Helper;
use Module\Form\FooForm;
use Zend\View\Helper\AbstractHelper;
use Zend\View\Model\ViewModel;
class FooFormHelper extends AbstractHelper
{
protected $fooForm;
protected $viewTemplate = 'module/layout/foo-form';
public function __construct(FooForm $fooForm)
{
$this->fooForm = $fooForm;
}
public function __invoke()
{
$vm = new ViewModel([
'form' => $this->fooForm;
]);
$vm->setTemplate($this->viewTemplate);
return $this->getView()->render($vm);
}
public function setViewTemplate($viewTemplate)
{
$this->viewTemplate = $viewTemplate;
}
}
@patrick-hertling
Copy link

Sweet stuff 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment