Symfony Forms Tutorial
Вставка
- Опубліковано 1 гру 2024
- ℹ In this recording I show you how to create and submit a form in Symfony. You'll need forms of some kind in pretty much any application you build so here I cover all the essentials including how to protect your application with frontend / backend validation and security against cross site request forgery.
🆓 Join garyclarke.tech for course DISCOUNTS and a FREE Docker + PHP course (worth $49)
www.garyclarke...
👇Follow me on Social Media:
Twitter: / garyclarketech
Linkedin: / garyclarketech
💕Show support:
www.paypal.com...
Chapters:
3:24 - Creating a form for your entity
4:40 - adding stuff to your Form
5:10 - working in Controllers (but why didn't you use make:controller for this?)
6:40 - Sending the form to the template
8:10 - including/showing the formin your template
9:04 start of validation
10:00: Submission handling
lucky people who understand English. I’m very interested, but I don’t understand half of it, but I’m watching with pleasure. The text was written through a translator. Thank you very much to the author!
Just dumping a few timestamps here that helped me
3:24 - Creating a form for your entity
4:40 - adding stuff to your Form
5:10 - working in Controllers (but why didn't you use make:controller for this?)
6:40 - Sending the form to the template
8:10 - including/showing the formin your template
9:04 start of validation
10:00: Submission handling
Will edit later, this is pretty much most stuff I needed
Cheers...I really appreciate that! Will paste in the description also 🤝
Thank you for delivering such great content!!🙌🍻
Thanks for this tutorial ... i am was looking for 2 days to understand this
Glad it helped 🤝
Neato, thanks. I was able to make my first Symfony/doctrine web app store new users thanks to you.
Nice work!
excellent video, thanks a bunch, keep helping young developer like myself
Hi Gary, thank you for this nice video about Symfony Forms. 👍😊 Only as a suggestion it would be great if you could create a short video about how to create a search form based on some entities too.
Thanks Nicolas. A few people have suggested the same thing so I'll propbably do it later this year.
Great video really helped me understand forms. How would I validate a form using php attributes intsead of annotations?
This should help. The docs now use attributes:
symfony.com/doc/current/validation.html#the-basics-of-validation
@@GaryClarkeTech Thats great! Thanks. Excellent tutorial by the way, clear and concise.
Thanks Gary! Very clear as always
Very welcome
Can you please tell us about the use of DTO, there is often a bunch of this model with a form
Thanks for the suggestion....I'll have a look at them next time I cover forms.
Hey Gary, great video! I was wondering if you have any idea how to fix a problem I have came across... during the step at 1:58 when you make the migration file I get an error in my console ( SQLSTATE[08006]) and I have no clue how to fix it?
You got the rest of the error?
Can we add an Object type in symfony forms? If yes how we can get it?)
Hi Gary you are doing amazing work. I have a question what I use custom html form and do you not configure csrf from the form type class or stuff. How can I use csrf directly in the HTML form and validate it in the controller. I am having trouble with it. Let's say I am try to create a simple post with HTML like form not using the formtype class
This should be what you need:
symfony.com/doc/current/security/csrf.html#generating-and-checking-csrf-tokens-manually
Hi Gary, since you're extending from AbstractController, it already has a render method calling the twig ins't it? So actually injecting the Envirionment $twig should not be needed?
Yes..and I would usually just use $this->render as it's less code. I just inject twig in my recordings so that people know how it works under the hood.
how to set labels? or how to hide them? Symfony Forms is setting label automatically for me but it's badly formatted, taking it directly from Entity.
There's a label example here
symfony.com/doc/current/forms.html#creating-forms-in-controllers
@@GaryClarkeTech Thanks man. I have not seen that. probab too quick to read thro when finding solution.
It's very clear. Thank you.
Glad it was helpful!
@@GaryClarkeTech FYI as a beginner it will be interesting for me to see how to build a frontend
Thanks for this
How to use forms in symfony which not related to entities ?
Maybe just use a plain old html form?