sulu-workshop
sulu-workshop copied to clipboard
06 - Add an event registration to the website
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 createdEventRegistration
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
- Next assignment pull request: 07 - Display the registrations for each event in the admin interface
- Source file of this assignment: assignments/06.md
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.
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
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 Thank you I updated the description!