Skip to content

Tag: symfony

Symfony access headers in custom validator constraint

I am trying to access the headers of my request in a custom validator constraint like so: But the headerBag in $this->request is always an empty array unfortunately. Is there maybe an issue because I extend the symfony count validator? Answer You should ingest RequestStack instead of Request See the docume…

Dynamic embedded form with OneToOne relationship

I’m trying to create a form for an article with an addon (tender). The article is in one-to-one relationship with the addon and the addon can be disabled (null). If the checkbox with an addon is checked, the addon needs to be validated, then submitted together with the article. The issue I’m havin…

PHP – Multiple OR operators in if statement

I am working with getters and setters within my Symfony project. I have to use if() statement to check if status field does not have specific values before changing other field. Code: I defined constants and also using OR operator. I was wondering if there is more elegant solution than this. Maybe is_array() …

Change parent format from @Template to render

When updating the app from Symfony 2.8 to Symfony 3.4, the handling of _format changed, so I would like to change @Template to render as shown in the post below. However, because twig is changed in Parent format Unable to specify twig file in return of BaseStaffController.php. Is there any good way? How to re…