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

КОМЕНТАРІ • 34

  • @disconnect3763
    @disconnect3763 5 місяців тому

    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!

  • @a.y5742
    @a.y5742 3 роки тому +3

    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

    • @GaryClarkeTech
      @GaryClarkeTech  3 роки тому

      Cheers...I really appreciate that! Will paste in the description also 🤝

    • @michaelbica9294
      @michaelbica9294 Рік тому

      Thank you for delivering such great content!!🙌🍻

  • @eTravelVlog
    @eTravelVlog 9 місяців тому

    Thanks for this tutorial ... i am was looking for 2 days to understand this

  • @kajetandziebaj6405
    @kajetandziebaj6405 Рік тому

    Neato, thanks. I was able to make my first Symfony/doctrine web app store new users thanks to you.

  • @swastikagarwal8605
    @swastikagarwal8605 Рік тому

    excellent video, thanks a bunch, keep helping young developer like myself

  • @purajhei-rendape
    @purajhei-rendape 3 роки тому +1

    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.

    • @GaryClarkeTech
      @GaryClarkeTech  3 роки тому

      Thanks Nicolas. A few people have suggested the same thing so I'll propbably do it later this year.

  • @ETERNAL_VOID
    @ETERNAL_VOID 2 роки тому +1

    Great video really helped me understand forms. How would I validate a form using php attributes intsead of annotations?

    • @GaryClarkeTech
      @GaryClarkeTech  2 роки тому +1

      This should help. The docs now use attributes:
      symfony.com/doc/current/validation.html#the-basics-of-validation

    • @ETERNAL_VOID
      @ETERNAL_VOID 2 роки тому

      ​@@GaryClarkeTech Thats great! Thanks. Excellent tutorial by the way, clear and concise.

  • @d_sportello
    @d_sportello 2 роки тому

    Thanks Gary! Very clear as always

  • @bakaleisanich
    @bakaleisanich 4 роки тому +1

    Can you please tell us about the use of DTO, there is often a bunch of this model with a form

    • @GaryClarkeTech
      @GaryClarkeTech  4 роки тому

      Thanks for the suggestion....I'll have a look at them next time I cover forms.

  • @yourmememajesty
    @yourmememajesty 2 роки тому

    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?

  • @boriskrasnov1672
    @boriskrasnov1672 Рік тому

    Can we add an Object type in symfony forms? If yes how we can get it?)

  • @digitaluniverse9826
    @digitaluniverse9826 3 роки тому

    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

    • @GaryClarkeTech
      @GaryClarkeTech  3 роки тому

      This should be what you need:
      symfony.com/doc/current/security/csrf.html#generating-and-checking-csrf-tokens-manually

  • @parijke
    @parijke 4 роки тому

    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?

    • @GaryClarkeTech
      @GaryClarkeTech  4 роки тому +2

      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.

  • @TomiBorchert
    @TomiBorchert 10 місяців тому

    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.

    • @GaryClarkeTech
      @GaryClarkeTech  10 місяців тому +1

      There's a label example here
      symfony.com/doc/current/forms.html#creating-forms-in-controllers

    • @TomiBorchert
      @TomiBorchert 10 місяців тому

      @@GaryClarkeTech Thanks man. I have not seen that. probab too quick to read thro when finding solution.

  • @bakaleisanich
    @bakaleisanich 4 роки тому

    It's very clear. Thank you.

    • @GaryClarkeTech
      @GaryClarkeTech  4 роки тому

      Glad it was helpful!

    • @bakaleisanich
      @bakaleisanich 4 роки тому

      @@GaryClarkeTech FYI as a beginner it will be interesting for me to see how to build a frontend

  •  3 роки тому

    Thanks for this

  • @mahmoudalhussain9291
    @mahmoudalhussain9291 3 роки тому

    How to use forms in symfony which not related to entities ?