Is it possible to call one of an entity's getter methods from Twig?
php, symfony, twig
Solution
Firstly you should change your property `private errorNum` to `protected errorNum` and then from your controller return:
return $this->render("AcmeDemoBundle:Product:create.html.twig", array('item' => $item));
Then in your twig view , you can access property:
{{item.errorNum}}
You can also access method :
{{item.ErrorNum}}
Problem
I have an entity like the below: ``` class item { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\Column(type="integer",nullable=true) */ private $errorNum; public function getErrorNum() { return $this->errorNUm * 3; } ``` I can access the `$errorNum` property in Twig like this after passing the entity to Twig: ``` {{ item.errorNum }} ``` However I want to access the `getErrorNum()` method from Twig. How can I do it?