Relations matching in Jetformbuilder
HelaG27 opened this issue · 2 comments
How would I accomplish this? I have two terms (taxonomies): country and city. They are related as one-to-many and all the relations are created (e.g., 10 countries and 10 cities for each country). In a registration form on jetformbuilder, I need when a user chooses a country like America (parent) in a selection field, a second selection field shows the related cities (children).
Hi @HelaG27!
Here is an example for Related Posts but you can change the Post Query to Term query and use this query
Show related post of the selected post
This can be achieved with this addon: https://github.com/ihslimn/jet-form-builder-update-field
Download and upload it to the website https://prnt.sc/rue-0hVJX-mO
Let me show you an example of how to display child posts of the selected parent posts.
First, we add a field that displays the parent CPT: https://prnt.sc/P8W6rM423Pjc
Then, we need to create a query that displays child posts dynamically. Create a Posts Query in JetEngine > Query Builder > Add New https://prnt.sc/ovq3yAv2bOvB
Move to the Post & Page tab and add the Related Items macro near the Post In setting: https://prnt.sc/NkcKcJd1-xdW
You need to select the needed relation, and the needed object, and under the Variable Name, enter the name of the field that displays parent posts.
Next, add a new form field under the existing one. It will display child posts.
Use the JetEngine Query Generator to get options from the query: https://jetformbuilder.com/features/multi-optional-field-source-settings/#generate-dynamically:~:text=%E2%80%9CGet%20values%20list%20from%20JetEngine%20Query.%E2%80%9D
Next, open the Field Updater tab of settings https://prnt.sc/4Q_euKhVVHT0
In the "Fields to listen" field, enter the name of the field that displays parent posts.
And done!
Thanks for the reply. I came across this solution and am sure it works for "related posts" but it doesn't work with "related terms." Or maybe there is something am not doing right, but I tried nearly all the fields/iterations in the "terms" query builder.