i have an ChoiceType::class input field in my form with, now just as an example, two choices: ‘choices’ => [‘type1’ => ‘1’, ‘type2’ => ‘2’] now when the user select type2 i want to add an exta TextType::class inputfield to the form. But i dont want to show the input field before and i want it to be required if
Tag: symfony-forms
Symfony – ChoiceType with multiple and resetViewTransformers returns invalid_message
We have upgraded our project to Symfony 4.4.35 2 months ago and now I noticed a strange behavior. When I use ChoiceType with the following configuration, the form returns error (This value is not valid): The POST: Can someone tell me what has changed? I have tried to inspect ChoiceType.php, and find out the problem is here: The question is:
Symfony Update data with a post request
I am currently trying to update a Person in a table. The Table looks the following: I want to be able to update the First-and Lastname and also the nin when I click on the Submit button. My twig file looks like this: And my controller is the following: Currently when I click update I just fill it what’s in
Using validation groups on EasyAdmin 3.x
I want to use validation groups with EasyAdmin 3.x when creating a new User to validate every field. I have a User entity with name, phone, and email fields and use @UniqueEntity in a “creation” group, so I can update the User in a form I created outside from EasyAdmin. That works just fine, but I can’t manage to find
Symfony 5.1 – Dynamically add a CustomType field before submitting
My problem is not that simple I will try to summarize as best as I can. Let’s say I have an entity Vehicle which is related to an entity Engine. Engine entity is an abstract type which is implemented by 2 classes : ElectricEngine and GasEngine. I want to create a form for Vehicle which will create a vehicle and
add html in the ‘help’ parameter of the formbuilder
I use the formbuilder in a Symfony project. I’d like to use as much as I can the {{ form_row(form) }} in my twig template to avoid writing errors, label, help and widget myself. In this particular …
Checking which form field value has changed Symfony 3
I need to check inside the FormType which field has changed. Is there any method to do it? I’ve searched for a while, then tried to get edited entities field in few ways (with form events too) to catch the edited fields, but no simple result. Is there any way to do it easy, or I need to be more
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
How to create a custom SaveType which is child of SubmitType in Symfony forms
I want to make some simple admin panel application in Symfony. I see that since version 2.3 Symfony introduced a Bootstrap’s form theming, which is great, but I want to create custom submit field called SaveType which should have default class attr set to btn-primary instead of btn-default. So, from documentation I read that I can create that custom field
Symfony form collection rendering
I’m using symfony 2.3 I have form with field of type “collection” Visualization code in twig: Everything work, expect when form.fields is empty. Then nothing is visualized in twig loop, witch is fine. But at the end of the form there is “label” for the element “form.fields”. Only label. Workaround: If there are elements, they will be rendered in the