[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
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?
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. **
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
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.