Skip to content
Advertisement

Symfony Update data with a post request

I am currently trying to update a Person in a table. The Table looks the following:

Table

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:

JavaScript

And my controller is the following:

JavaScript

Currently when I click update I just fill it what’s in the “setFirstName(‘FirstName’);”. I don’t really know how to pass in the correct data so it updates correctly? how would I obtain the changes I want to make by pressing submit?

Advertisement

Answer

The quick fix (not recommended):

You should add the name attribute for text input tags

JavaScript

and modify controller:

JavaScript

But for the best practice, you should use Symfony Form Collection and add validation rules for fields

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement