Skip to content

Instantly share code, notes, and snippets.

@danaketh
Created January 11, 2014 00:38
Show Gist options
  • Save danaketh/8365411 to your computer and use it in GitHub Desktop.
Save danaketh/8365411 to your computer and use it in GitHub Desktop.
Just a basic Twig extension to support Yii ActiveForm
namespace danaketh/twig/ext;
use Yii;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
class TwigActiveForm extends \Twig_Extension
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'ActiveForm';
}
/**
* {@inheritdoc}
*/
public function getGlobals()
{
return array(
);
}
/**
* {@inheritdoc}
*/
public function getFunctions()
{
return array(
"form_begin" => new \Twig_Function_Method($this, 'begin'),
"form_end" => new \Twig_Function_Method($this, 'end'),
);
}
/**
* {@inheritdoc}
*/
public function getFilters()
{
return array(
);
}
public function begin($args)
{
return ActiveForm::begin($args);
}
public function end()
{
ActiveForm::end();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment