Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
55097dc6
Commit
55097dc6
authored
Oct 09, 2011
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added a way to configure the form templates (based on patch #143)
parent
2ad52f98
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
doc/providers/twig.rst
doc/providers/twig.rst
+3
-0
src/Silex/Provider/TwigServiceProvider.php
src/Silex/Provider/TwigServiceProvider.php
+6
-2
No files found.
doc/providers/twig.rst
View file @
55097dc6
...
@@ -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
--------
--------
...
...
src/Silex/Provider/TwigServiceProvider.php
View file @
55097dc6
...
@@ -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
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment