@@ -35,6 +35,8 @@ class FormHelper extends Helper
3535
3636 protected  $ themes
3737
38+  protected  $ templates
39+ 
3840 /** 
3941 * Constructor; 
4042 * 
@@ -46,7 +48,8 @@ public function __construct(EngineInterface $engine, array $resources = array())
4648 $ this engine  = $ engine
4749 $ this varStack  = array ();
4850 $ this context  = array ();
49-  $ this themes  = new  \SplObjectStorage ();
51+  $ this templates  = array ();
52+  $ this themes  = array ();
5053
5154 $ this resources  = 0  == count ($ resourcesarray ('FrameworkBundle:Form ' ) : $ resources
5255
@@ -72,7 +75,8 @@ public function isChoiceSelected(FormView $view, $choice)
7275 */ 
7376 public  function  setTheme (FormView $ view$ themes
7477 {
75-  $ this themes [$ viewarray ) $ themes
78+  $ this themes [$ viewget ('id ' )] = (array ) $ themes
79+  $ this templates  = array ();
7680 }
7781
7882 /** 
@@ -274,43 +278,47 @@ public function renderBlock($name, $variables = array())
274278 return  $ this engine ->render ($ template$ variables
275279 }
276280
281+  public  function  getName ()
282+  {
283+  return  'form ' ;
284+  }
285+ 
277286 /** 
278287 * Returns the name of the template to use to render the block 
279288 * 
280-  * @param FormView $view   The form view 
281-  * @param string $blockName  The name of the block 
289+  * @param FormView $view The form view 
290+  * @param string $block  The name of the block 
282291 * 
283292 * @return string|Boolean The template logical name or false when no template is found 
284293 */ 
285294 protected  function  lookupTemplate (FormView $ view$ block
286295 {
287- 
288296 $ file$ block'.html.php ' ;
297+  $ id$ viewget ('id ' );
289298
290-  $ themes$ viewhasParent () ? array () : $ this resources ;
299+  if  (!isset ($ this templates [$ id$ block
300+  $ templatefalse ;
291301
292-  if  ($ this themes ->contains ($ view
293-  $ themesarray_merge ($ themes$ this themes [$ view
294-  }
302+  $ themes$ viewhasParent () ? array () : $ this resources ;
295303
296-  for  ($ icount ($ themes1 ; $ i0 ; --$ i
304+  if  (isset ($ this themes [$ id
305+  $ themesarray_merge ($ themes$ this themes [$ id
306+  }
297307
298-  $ template$ themes$ i': ' .$ file
308+  for  ($ icount ($ themes1 ; $ i0 ; --$ i
309+  if  ($ this engine ->exists ($ templateName$ themes$ i': ' .$ file
310+  $ template$ templateName
311+  break ;
312+  }
313+  }
299314
300-  if  ($ this -> engine -> exists ( $ template 
301-  return   $ template
315+  if  (false  ===  $ template  &&  $ view -> hasParent ( )) {
316+  $ template =  $ this -> lookupTemplate ( $ view -> getParent (),  $ block ) ;
302317 }
303-  }
304318
305-  if  ($ viewhasParent ()) {
306-  return  $ this lookupTemplate ($ viewgetParent (), $ block
319+  $ this templates [$ id$ block$ template
307320 }
308321
309-  return  false ;
310-  }
311- 
312-  public  function  getName ()
313-  {
314-  return  'form ' ;
322+  return  $ this templates [$ id$ block
315323 }
316324}
0 commit comments