<p>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.</p>

<p>I'm thinking the registration flow should go:</p>

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

<p>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.</p>

<p>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?</p>

CC BY-SA 4.0
2020-04-26T10:36:28.233Z
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
CC BY-SA 4.0
2020-04-27T03:32:30.717Z
Thanks @MaxStrebel, that’s a really good thought. I’m just wondering how I would get that parent ID after submission?
revlis
CC BY-SA 4.0
2020-04-27T03:48:52.343Z
As per this question: https://craftcms.stackexchange.com/questions/10060/get-the-id-of-a-new-entry-when-its-saved

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?
revlis
CC BY-SA 4.0
2020-04-27T10:04:57.877Z
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
<craft3>
Parent/Children Users
# Parent/Children Users

(Asked by: username_0 on 2020-04-26)

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?

**Tags:** craft3
> **Comments:**
> **username_1**: 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.  
> **username_0**: Thanks @MaxStrebel, that’s a really good thought. I’m just wondering how I would get that parent ID after submission?  
> **username_0**: As per this question: https://craftcms.stackexchange.com/questions/10060/get-the-id-of-a-new-entry-when-its-saved  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?  
> **username_1**: 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 ;)  

---

## 0 answers

