Skip to content
Advertisement

Tag: twig

Manually switch _locale in symfony 4

I’m absolutely stuck in getting a solution to manually switch the _locale variable in Symfony 4. I followed these steps, but now I have absolutely no idea how to make a simple switch button in the nav section. I also took a look a this question, but this seems to be an older Symfony version.. Can anyone please help me

SVG icon in twig template

I’m struggling with svg icons. I’m creating menu and to do this I have to use several of svg icons. I already know, that if I want to manipulate colour with help CSS (for example when icon is active/hover) I have to use in HTML <svg> tag not <img src=”path-to-icon.svg”/>. How can I solve this problem in a nice way?

Twig accessing protected/private model variables

I have a problem with Twig, (in fact this is not really a problem but it’s disturbing to me) I have a Post model class in php and i have some protected variables (I also tried with private). To acces them I have a public function in php getMyVariable. If in my controller I try to echo the protected variable

Impossible to access an attribute on a string variable

In my controller i just pass some users on my twig view. Here is my function : And this is my twig view where i want to display some information on a html table : And i got this error : Impossible to access an attribute (“name”) on a string variable (” “). for this line : Thanks for help!

Symfony: pass parameter to Ajax url

I am trying to figure out how to enable/disable user with checkbox without page reload. index.html.twig UserController Question How can I set corresponding user id to enabledChange function and change checked state depending on user state? Answer You need to add quotes to your variables, and pass changePath as an argument: then: I hope this will help.

How to render json into a twig in Symfony2

The question is how to pass a json to twig to render a template. I’ve tried to pass a json with JsonResponse object but I did not find the way to render the template. TarifasController.php index.html.twig How can I pass a json from the controller to use it in the DataTable (in twig template) but mantaining the render in this

Advertisement