sulu-workshop icon indicating copy to clipboard operation
sulu-workshop copied to clipboard

06 - Add an event registration to the website

Open luca-rath opened this issue 4 years ago • 4 comments

Allow for event registration on the website

Goal

We want to allow our users to register themselves for our events in the future. Therefore we need to display a register form that includes input fields for a email address, a first and last name on each event detail page.

Steps

  • Follow the symfony best practices to add a new EventRegistration entity
  • Add a many-to-one association between the Event entity and your newly created EventRegistration entity
  • Don't forget to update your database schema with bin/adminconsole doctrine:schema:update --force
  • Follow the symfony best practices to add a new EventRegistration form type
  • Persist submitted registrations in your src/Controller/Website/EventWebsiteController.php
  • Output your form and a success message in your templates/events/index.html.twig
  • Browse one of your events and register yourself

Hints

  • Use bin/adminconsole make:entity EventRegistration
  • https://symfony.com/doc/current/doctrine.html#creating-an-entity-class
  • Use bin/adminconsole make:form EventRegistrationType EventRegistration
  • https://symfony.com/doc/current/best_practices/forms.html
  • Run bin/adminconsole doctrine:schema:validate

More Information

This assignment is purely based on Symfony. No Sulu knowledge required ;-)

Links

luca-rath avatar Jul 07 '20 10:07 luca-rath

Hi,

beautifull documentation as PR. Very usefull. But I think that the reference to the new controller is missing in the config/templates/pages/event_overview.xml If not i missed something.

sebheitzmann avatar Feb 27 '21 05:02 sebheitzmann

Hi and thanks for your feedback! 🙂

The EventWebsiteController is not used for the event overview, it's used for the event detail page. There is a custom route defined in config/routes_website.yaml

luca-rath avatar Feb 27 '21 08:02 luca-rath

Hi, great tutorial!

I think under Hints it should be bin/adminconsole make:form EventRegistraionType EventRegistration instead of EventType Event

and src/Controller/EventWebsiteController.php is located under src/Controller/Website/EventWebsiteController.php

Wonko52 avatar Apr 23 '22 21:04 Wonko52

@Wonko52 Thank you I updated the description!

alexander-schranz avatar Apr 25 '22 08:04 alexander-schranz