0

I'm building a site for a soccer school, where parents will register their children into classes. Aside from a standard registration page, I want to assign photos to children so parents can quickly see photos with their child, and allow parents to RSVP to events.

I'm thinking the registration flow should go:

  • the parent enters their details in a standard form (creates a user)
  • redirected to the 'next page' which is another standard form to enter child details (creates an entry)
  • the age group they select for their child is the class they will join (a category)

Parents as users can then see the entries belonging to them (their children) and those entries are assigned to a category (the class). I can then upload assets to the entries (children) which the parents will see as 'author' of the entry.

Does anyone have any other potential ways of doing this? If I go for this method, I'm trying to find a way to pass the author ID to step 2 where they enter their child's details, so that entry is automatically assigned to them. Does anyone have any ideas on that?

  • You could try to create a Field 'Parent' which is an Entry Field. This could establish the relation to the first Entry (the parent). Then pass the ID of the parent to Step 2 (via URL parameter). On step 2 you could get the ID parameter from the url and submit the ID of the Parent's Entry into the field via a hidden input. On submission this might save the Relation to the parent. This way you could query parents and Children via relatedTo. – Max Strebel Apr 26 at 10:36
  • Thanks @MaxStrebel, that’s a really good thought. I’m just wondering how I would get that parent ID after submission? – tommysvr Apr 27 at 3:32
  • As per this question: craftcms.stackexchange.com/questions/10060/… I added <input type="hidden" name="action" value="users/save-user"> <input type="hidden" name="redirect" value="child/{id}"> on the form and then 'child/(?P<id>\d+)' => ['template' => '_content/pages/child'] in config/routes.php but just get an HTTP 400 Bad Request: Request contained an invalid body param error. Which I guess is because it can't get the ID of something that hasn't been created yet? – tommysvr Apr 27 at 3:48
  • Oh okay, this might need to be done at the end, then. So when everything is fine and you create the entries, you establish the connection? First the parent, then the Children. Sorry, it's a bit hard without the actual code ;) – Max Strebel Apr 27 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.