Commit 55097dc6 authored by Fabien Potencier's avatar Fabien Potencier

added a way to configure the form templates (based on patch #143)

parent 2ad52f98
...@@ -19,6 +19,9 @@ Parameters ...@@ -19,6 +19,9 @@ Parameters
* **twig.class_path** (optional): Path to where the Twig * **twig.class_path** (optional): Path to where the Twig
library is located. library is located.
* **twig.form.templates** (optional): An array of templates used to render
forms (only available when the ``FormServiceProvider`` is enabled).
Services Services
-------- --------
......
...@@ -51,9 +51,13 @@ class TwigServiceProvider implements ServiceProviderInterface ...@@ -51,9 +51,13 @@ class TwigServiceProvider implements ServiceProviderInterface
} }
if (isset($app['form.factory'])) { if (isset($app['form.factory'])) {
$twig->addExtension(new TwigFormExtension(array('form_div_layout.html.twig'))); if (!isset($app['twig.form.templates'])) {
$app['twig.form.templates'] = array('form_div_layout.html.twig');
}
// add loader for form_div_layout.html.twig $twig->addExtension(new TwigFormExtension($app['twig.form.templates']));
// add loader for Symfony built-in form templates
$reflected = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension'); $reflected = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
$path = dirname($reflected->getFileName()).'/../Resources/views/Form'; $path = dirname($reflected->getFileName()).'/../Resources/views/Form';
$app['twig.loader']->addLoader(new \Twig_Loader_Filesystem($path)); $app['twig.loader']->addLoader(new \Twig_Loader_Filesystem($path));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment