Home › Toolset Professional Support › [Resolved] How to make the selected post in generic filed view the post parent
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 |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10: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/Kolkata (GMT+05:30)
Tagged: Types plugin, Views plugin
This topic contains 14 replies, has 2 voices.
Last updated by Minesh 5 years, 2 months ago.
Assisted by: Minesh.
Tell us what you are trying to do?
I want to make the selected post in generic filed view to be post parent.
Hello. Thank you for contacting the Toolset support.
Can you please share more details about your problem what exactly you are looking for.
Do you mean you have post form where you have a generic select field added and with this field you want to display the parent posts that belong to the current post where this form is added?
I have a child post type called communication. This child post type has a parent post type called rental. Where rental has a parent called tenant. For tenant I have child post type called contact.
So, what I have now is when I create new communication it will be a child for a specific rental.
Now I want also to have a field in the communication form where I can select which contact of the tenant that communication should be linked with (that is why I am using generic field with view of contacts for current tenant). So, At the end after submitting the form I want to know this communication is for which rental and which contact.
Ok - thanks I understand the structure.
However - do you have any relationship
Basically, when you submit the form, you are connecting communication with the rental. Now there is no relationship between contact and communication. so without the relationship, we can not connect the posts.
Normally, Toolset offers post-relationship API and you can use the function toolset_connect_post() that you can use with the Forms API hook cred_save_data:
For example:
add_action('cred_save_data','func_connect_contact',10,2); function func_connect_contact($post_id,$form_data) { if ($form_data['id']==9999) { // your code goes here } }
Where:
- Replace 9999 with your original form ID
More info:
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
I do have relationship between contact and communication. However, I don't know how to link the communication post to be child of rental and contact when submitting the form. For now I can link it only with rental.
Ok - I would like to know where exactly you have added the form? is form added on the single post of the parent (rental)? Does your form have the parent selector?
If you can share problem URL and access details I can review it quickly and guide you accordingly.
I have set the next reply to private which means only you and I have access to it.
Yes I am using parent selector but it will show all the contacts not only the contacts for the specific tenant.
Ok - there is no native way to filter the relationship select boxes. However - I would still like to know from where you want to get the information that you want to load these specific tenant's related posts?
Do you mean as the form is added on rental post based on rental post ID get the related specific tenant and load all the contacts belongs to this specific tenant?
"Do you mean as the form is added on rental post based on rental post ID get the related specific tenant and load all the contacts belongs to this specific tenant?"
Yes
Opps - really complicated 🙂
So, as I acknowledged that there is no native way to do it but I can share the workaround if that helps otherwise there is no way.
But I need access details to check the fields and relationships. Can you please share the problem URL and access details.
I have set the next reply to private which means only you and I have access to it.
Can you please share the link where you added the form?
Can you please send me FTP access details as I need to add the code to theme's functions.php file to run a test.
I'm checking the Layout for rentals you added:
=> hidden link
And now, on single rental page where the contact tab is added, I do not see anything and when I checked the Layout, from the contact tab there is nothing added. Are you working on the site and changed anything? Can you please share where I can see the Form now?
The link for communication form in Rental communication view in communication tab.
Ok - with FTP, I was able to debug this further and now the core codebase has been changed for the forms and there is no way to filter the parent select2 options as there is no filter available to filter the results.
Only thing I can do is to encourage you to file a new feature request using the following link:
=> https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/