Symfony Forms Tutorial

Поделиться
HTML-код
  • Опубликовано: 11 ноя 2020
  • ℹ 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.tech
    👇Follow me on Social Media:
    Twitter: / garyclarketech
    Linkedin: / garyclarketech
    💕Show support:
    www.paypal.com/donate/?hosted...
    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 3 дня назад

    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!

  • @swastikagarwal8605
    @swastikagarwal8605 Год назад

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

  • @d_sportello
    @d_sportello 2 года назад

    Thanks Gary! Very clear as always

  •  2 года назад

    Thanks for this

  • @kajetandziebaj6405
    @kajetandziebaj6405 10 месяцев назад

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

  • @eTravelVlog
    @eTravelVlog 4 месяца назад

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

  • @bakaleisanich
    @bakaleisanich 3 года назад

    It's very clear. Thank you.

    • @GaryClarkeTech
      @GaryClarkeTech  3 года назад

      Glad it was helpful!

    • @bakaleisanich
      @bakaleisanich 3 года назад

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

  • @a.y5742
    @a.y5742 2 года назад +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  2 года назад

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

    • @michaelbica9294
      @michaelbica9294 Год назад

      Thank you for delivering such great content!!🙌🍻

  • @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.

  • @digitaluniverse9826
    @digitaluniverse9826 2 года назад

    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  2 года назад

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

  • @parijke
    @parijke 3 года назад

    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  3 года назад +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.

  • @bakaleisanich
    @bakaleisanich 3 года назад +1

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

    • @GaryClarkeTech
      @GaryClarkeTech  3 года назад

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

  • @yourmememajesty
    @yourmememajesty Год назад

    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 9 месяцев назад

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

  • @ETERNAL_VOID
    @ETERNAL_VOID Год назад +1

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

    • @GaryClarkeTech
      @GaryClarkeTech  Год назад +1

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

    • @ETERNAL_VOID
      @ETERNAL_VOID Год назад

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

  • @mahmoudalhussain9291
    @mahmoudalhussain9291 2 года назад

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

  • @TomiBorchert
    @TomiBorchert 5 месяцев назад

    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  5 месяцев назад +1

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

    • @TomiBorchert
      @TomiBorchert 5 месяцев назад

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