I have this PHP code that works but I would like to be able to use the same but within twig in symfony. Answer To make this code guide me in this post: https://es.stackoverflow.com/a/73288/6524 The only variant in the file EdadUsuarioExtension.php
Tag: symfony
PHP Symfony Many to Many form
I have a many-to-many relationship between two tables in my database (1 artikel has more than 1 bestelling and vice versa), so I made a link table(bestelregel). But now I want to make a form so that I can add a new order with multiple products, but as I am new to this, I am not sure how to do
Validate against several constraints with OR logic in Symfony
I have a field in a request which can either be email or phone. Now I need to validate it against two constraints – the standard email constraint and a custom phone. I know that I can pass an array of constrains link this: But Validator applies the AND logic to the array of constraints, I need OR so that
Warning: Illegal offset type in isset or empty
I have two Doctrine entities: Page and Synonym. Each Page contains references to several Synonyms, and I want to make sure that no Synonym names are duplicated. So I create a symfony command that runs through the synonyms on a page, checking for duplicates: So far, so good. But when I run my command, I find that the $page->removeSynonym($synonym); line
Price Alert:How to pass price product from a list of profucts to a popup?
I’m having a list of specific products,foreach product I have a button Create Price Alert.When I click on the button a pop up shows up and contains the price of the current product : <link href="{{…
Return data from Doctrine inside a JsonResponse object
My problem is that I want to return some data that I get from Doctrine inside a JsonResponse object. I get the data with a QueryBuilder, like this: However, the data inside the JsonResponse looks empty: Does anyone know how I can return the data this way correctly? Answer I think you’re getting the array of Users correctly from the
Symfony 4 make:entity {entity} generate in a custom directory in a multi doctrine connection
New to symfony here I have a two connection setup in my config/packages/doctrine.yaml. Is it possible to generate an Entity class using the cli tool php bin/console make:entity Product to generate entity in a custom directory. When I run the above command the “Product” enttity class gets generated in my src/Entity/ directory but I want it to be generated according
Annotations in Symfony 4
I try to develop with Symfony 4 so I follow the tutorial on symfony.com I’ve got an error when I try to access at : This is the error : [Syntax Error] Expected PlainValue, got ”’ at position 7 in method AppControllerHomeController::home() in /Users//Documents/ProjetSymfo4/my-project/config/routes/../../src/Controller/ (which is being imported from “/Users//Documents/ProjetSymfo4/my-project/config/routes/annotations.yaml”). Make sure annotations are installed and enabled. I already ran
Creating a Symfony 4 Form without Database
I’m new to symfony and want to to create a simple contact form, take the submitted values and send them as an Email. I don’t want to save anything in the database. I followed the documentation on this page: https://symfony.com/doc/current/form/without_class.html I created a new page/action with the code from the page above: But this gives me an error: What am
Doctrine – Hydrate collection in Entity class
I have a problem regarding a bi-directional OneToMany <-> ManyToOne relationship between my entities Device and Event. This is how mapping looks: The problem comes because Device is a Single Table Inheritance entity and each time I fetch and iterate over some Event entities, then $device is always eagerly fetched. This happens because it’s a STI entity as reported in