Twig_Error_Syntax: A message inside a trans tag must be a simple text

Quick tip: When have a code like this: {% raw %}{% trans %}prefix.{{ varname }}{% endtrans %}{% endraw %} And receive this error: Twig_Error_Syntax: A message inside a trans tag must be a simple text You can use the following piece of code as workaround. {% raw %}{{ ("prefix." ~ varname)|trans }}{% endraw %} PS: maybe this is not the best way to go.

January 15, 2014

Symfony 2: Inheritance and UniqueEntity workaround

Hi folks, Today I struggled over an already known bug on Symfony2 when using UniqueEntity and Entity Inheritance. In the bug discussion, @gentisaliu recommended using a custom repository, and how do this I’m documenting here. Entities: /** * @ORM\Table(name="parent") * @ORM\Entity(repositoryClass="Repository\Parent") * @UniqueEntity(fields={"name"}, repositoryMethod="findByName", message="Name already used.") * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="type", type="string") * @ORM\DiscriminatorMap({ * "a" = "ChildA", * "b" = "ChildB" * }) */ class Parent { } /** * @ORM\Entity(repositoryClass="Repository\Parent") * @ORM\Table(name="child_a") */ class ChildA extends Parent { } /** * @ORM\Entity(repositoryClass="Repository\Parent") * @ORM\Table(name="child_b") */ class ChildB extends Parent { } repositoryMethod: ...

November 27, 2013