Setting the Auto Parent-Child Relation to Posts Via a Front End Form (Legacy)
Create a form for Child posts and display it on a Single template for Parent posts. It will have a required One to Many relation if you insert the relation meta key in the right field of the Form.
Before you start, check the tutorial requirements:
- Elementor (Free version) or Block editor (Gutenberg)
- JetEngine plugin installed and activated
with the Relations (Legacy) configured and the Forms (Legacy) module enabled.
Create a Post Types Relation
Make sure that you do have the necessary post types to be interrelated. If not, create them. We’ll be referring to these two: Country & Tour. To create a relation, go to JetEngine > Relations and set the One to Many relation as shown below:
![country tour relation settings](https://crocoblock.com/knowledge-base/wp-content/uploads/2022/09/country-tour-relation-settings.png)
Create a Test Form
Go to JetEngine > Forms > Add New and create a form that allows adding a new post from the frontend:
![test form settings](https://crocoblock.com/knowledge-base/wp-content/uploads/2022/09/test-form-settings.png)
In the Post-submit actions, configure the notification type like so:
![form notification settings](https://crocoblock.com/knowledge-base/wp-content/uploads/2022/09/notification-type-settings.png)
The relation meta key can be taken from here:
![legacy relations meta key](https://crocoblock.com/knowledge-base/wp-content/uploads/2022/09/relation-meta-key-2.png)
Display the Form on the Front-end
Open the Tour CPT and find the necessary post in the WordPress dashboard.
![cpt post in the dashboard](https://crocoblock.com/knowledge-base/wp-content/uploads/2022/09/single-tour-page.png)
If it doesn’t exist, you need to create it either in the Elementor theme builder or in the Crocoblock theme builder:
![edit tour single page](https://crocoblock.com/knowledge-base/wp-content/uploads/2022/09/editing-tour-single-page.png)
Display the newly-created test form:
![form in elementor](https://crocoblock.com/knowledge-base/wp-content/uploads/2022/09/form-in-elementor.png)
Fill in the Form
On the front-end, try filling out the added form and press the “Add new post” button:
![front end form submission](https://crocoblock.com/knowledge-base/wp-content/uploads/2022/09/test-form-on-the-frontend.png)
Go to the backend and check out the result. You’re done!
![submitted test post](https://crocoblock.com/knowledge-base/wp-content/uploads/2022/09/test-tour-in-wp-admin-panel.png)