Json field in Mysql display in Twig but empty in Controller

I have a problem to use json variable in Controller. I have an entity with a json field :

* @ORM\Column(type="json", nullable=true) */  private $tagsEntiteMere = [];  public function getTagsEntiteMere(): ?array {    return $this->tagsEntiteMere; }  public function setTagsEntiteMere(?array $tagsEntiteMere): self {    $this->tagsEntiteMere = $tagsEntiteMere;     return $this; } 

The Mysql Datatable contain : {"tagsGroupe": ["tag1", "tag2"]}

In my twig template no problem : i can display, tag1 and tag2 with a basic code :

{% for tag in app.user.entiteActive.tagsEntiteMere.tagsGroupe %}   {{tag}} {%endfor%} 

But in my controller, the variable is empty :

$tags = $entite->getTagsEntiteMere(); print_r($tags); 

… this code show : Array()

So I don’t understand why in twig the variable contain value off Mysql datatable but in controller the same variable is empty.

Have you any ideas ? How solve it ?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.