Thursday, October 14, 2010

Symfony arrays from actions turn into sfOutputEscaperArrayDecorator objects in template.

In symfony a common problem is that arrays that are passed on from the action to the template are turned into sfOutputEscaperArrayDecorator. Then functions like is_array($testArray) won't work anymore.
this->testArray = array('1'=>'a', '2'=>'b', '3'=>'c');

Turning output escaping off

This happens when you have output escaping enabled in Symfony.
If you don't need it you can turn it off in:
Find the entry and set it to false.
   escaping_strategy:    false

Solution with keeping output escaping enabled

In the action.class.php:
this->testArray = array('1'=>'a', '2'=>'b', '3'=>'c');
In the template.php:
$myArray = $sf_data->getRaw('testArray');


Post a Comment