@@ -236,8 +236,9 @@ protected function render(FormView $view, $section, array $variables = array())
236
236
/**
237
237
* Returns the templates used by the view.
238
238
*
239
- * templates are looked for in the following resources :
239
+ * Templates are looked for in the resources in the following order :
240
240
* * resources from the themes (and its parents)
241
+ * * resources from the themes of parent views (up to the root view)
241
242
* * default resources
242
243
*
243
244
* @param FormView $view The view
@@ -247,31 +248,25 @@ protected function render(FormView $view, $section, array $variables = array())
247
248
protected function getTemplates (FormView $ view )
248
249
{
249
250
if (!$ this ->templates ->contains ($ view )) {
250
- // defaults
251
- $ all = array ();
252
-
253
- // themes
251
+ $ resources = array ();
254
252
$ parent = $ view ;
255
253
do {
256
254
if (isset ($ this ->themes [$ parent ])) {
257
- $ all = array_merge ($ this ->themes [$ parent ], $ all );
255
+ $ resources = array_merge ($ this ->themes [$ parent ], $ resources );
258
256
}
259
257
} while ($ parent = $ parent ->getParent ());
260
258
261
- $ all = array_merge ($ this ->resources , $ all );
259
+ $ resources = array_merge ($ this ->resources , $ resources );
262
260
263
261
$ templates = array ();
264
- foreach ($ all as $ resource ) {
262
+ foreach ($ resources as $ resource ) {
265
263
if (!$ resource instanceof \Twig_Template) {
266
264
$ resource = $ this ->environment ->loadTemplate ($ resource );
267
265
}
268
266
269
- $ blocks = array ();
270
267
foreach ($ this ->getBlockNames ($ resource ) as $ name ) {
271
- $ blocks [$ name ] = $ resource ;
268
+ $ templates [$ name ] = $ resource ;
272
269
}
273
-
274
- $ templates = array_replace ($ templates , $ blocks );
275
270
}
276
271
277
272
$ this ->templates ->attach ($ view , $ templates );
0 commit comments