Skip Navigation

[Resolved] One to Many relationship in a form

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

Problem:

Action hook cred_success_redirect is not working with my relationship form

Solution:

It is still in "feature request" status

Relevant Documentation:

This support ticket is created 2 years, 11 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 3 voices.

Last updated by trulsD 2 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2272171

Hi.
I have a CPT A with a "one to many" relationship with a CPT B.
Is it possible to have a multi-select in the form for creating a new CPT A?

Truls

#2272247

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You can include a selector for the "one" part of relationships in standard forms, but the "many" part would require using a relationship form.

So in your case if you have CPT A << CPT B (B is a child of A), in the form to publish a CPT B you can include a selector to choose the A the new B will belong to. (If you have the relationship already set up when you create the form, this selector will automatically be added.)

You can't have a form to publish CPT A and include a selector for which CPT B's to connect to it (because there could be many B's).

See
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/
https://toolset.com/course-lesson/front-end-relationship-forms-for-connecting-posts/

#2272295

Hi Nigel
I thought so.
I am in the process of creating a pop-up window that contains the relationship form.
The form for CPT A will have a button that opens a new window, and when the relationships are set, the window closes, and the original window appears.
The button in the form for CPT A must save the form set the postid as an URL param.
I have everything, but the save action.
Can I use a submit button, or do I have to use custom PHP code?

Truls

#2273601

Hello,

Please elaborate the question with more details:

The button in the form for CPT A must save the form set the postid as an URL param.

What kind of URL parameter are we talking about? How and where do you setup this URL parameter?
Please provide detail steps to reproduce the same problem

#2275545

Hi
I solved the "pop-up" window with cred_success_redirect and an isset($_POST['form_submit']) check in a PHP function. Now I have another problem.
cred_success_redirect is not working with my relationship form (it is a many to many relationship). I read the post "form hooks not working with relationship form" - https://toolset.com/forums/topic/form-hooks-not-working-with-relationship-form/
Do you know if there is a fix coming out soon? And is there a workaround?

Truls

#2275855

For the new question, I have checked it in our to-do list, it is still in "feature request" status, and I have added this thread into it, hope it can raise our developers's attention.

#2276077

Hi Lou.
I solved the redirect issue with javascript.
I have another question. Is it possible to have a "multi-select" dropdown in a "many to many" relationship form?

Truls

#2276979

According to our support policy, we prefer one ticket one question, for the new question, please check the new thread here:
https://toolset.com/forums/topic/is-it-possible-to-have-a-multi-select-dropdown-in-a-many-to-many-relationship-form/

#2277371

My issue is resolved now. Thank you!