Skip Navigation

[Resolved] Automatically set parent post in form for repeatable field group

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user would like to have the parent post selected automatically in a form.

Solution:
Regarding the first question, you will need to put the form inside a content template that is bound to the parent post. For example, create a view that will query the "Member" posts where the current user is the author, it should return one post if the user has already a post. Inside the loop, which is bound to that post, you can put the form and use the technique in the following article or the following similar tickets:
- https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/#creating-forms-when-a-parent-post-is-preselected

- https://toolset.com/forums/topic/repeatable-field-group-form-auto-select-post-where-this-form-is-shown-elementor/
- https://toolset.com/forums/topic/set-a-default-parent-value-for-a-repeating-field-group-front-end-form/

The trick is to bind the post using a content template, using the item attribute, or inside a view's loop.
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

Relevant Documentation:

100% of people find this useful.

This support ticket is created 3 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by marcialB 3 years, 3 months ago.

Assisted by: Jamal.

Author
Posts
#1859361
toolset.PNG

Hi there

We have a custom post type called "members". Each user on our platform can create such a "member". Within that member profile, the users should be able to add the experiences they have. For that, we created a repeating field group with a form.

I followed this (https://toolset.com/course-lesson/front-end-forms-for-repeatable-field-groups/#creating-a-form-for-repeatable-field-groups) documentation, but the selection of the parent post doesn't work. Probably it's because we added the form not to the post itself (e. g. domain.com/member/mister-x) but instead to a layout that allows the users to control their data from a general page on /my-profile. Now instead of automatically choosing the right "member" post, a dropdown appears within the repeating field group form where the user can select his or her member profile. Is there a way to automate that and hide the dropdown? A user will always only have one member profile.

And I have another question. We use Avada and the form is embedded in a modal on that page. Everything appears normal but the dropdown I mentioned is hidden behind the modal. I only spotted it by chance. I tried all possible combinations of z-index, but it seems I didn't find the right element to target to have the dropdown in front of everything. Do you have an idea of how the fix that?

Thanks a lot for your help!

#1859835

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting the Toolset support.

Regarding the first question, you will need to put the form inside a content template that is bound to the parent post. For example, create a view that will query the "Member" posts where the current user is the author, it should return one post if the user has already a post. Inside the loop, which is bound to that post, you can put the form and use the technique in the following article or the following similar tickets:
- https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/#creating-forms-when-a-parent-post-is-preselected

- https://toolset.com/forums/topic/repeatable-field-group-form-auto-select-post-where-this-form-is-shown-elementor/
- https://toolset.com/forums/topic/set-a-default-parent-value-for-a-repeating-field-group-front-end-form/

The trick is to bind the post using a content template, using the item attribute, or inside a view's loop.
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

Regarding the second issue, I'll need to take a closer look at your site to check this further. I assume that I'll need to connect, right? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1861439

Hi Jamal

Thanks for your feedback. I was able to solve it by inserting the form in my view (because I didn't want to implement the form on the post directly) und used the argument

value="$current"

within the parent post selector like this:

[cred_field field='@*****.parent' class='form-control' output='bootstrap' select_text='*****' required='true' value="$current" author='$current']

For the edit forms I created a new view that loads the custom field groups created by to the logged in author. In that view, I don't show any of the content but the edit form instead. The same goes for the delete link.

Regarding the other issue: this isn't relevant anymore.

Thanks again for your help!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.