Skip Navigation

[Resolved] Parent field -> in Child form -> on Parent template

This support ticket is created 6 years, 2 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 5 replies, has 2 voices.

Last updated by Luo Yang 6 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1136234

Hey Luo,

i have i question if this is possible.
Here is what i try to do:

I have:
1. Custom Post type (Job) which is the parent
2. Custom post type (Application) which is the child
3. Relation is set in one to one relationship
4. Template for the parent custom post type (Job) is set
5. Form for child custom post type (application) is set and displayed on the parents (jobs) template

Everything fine till here.

Now i wonder if it is possible to have in the child form a field (generic or what ever) from the parent post.
e.g. lets say on the parent post there is a field called "email". So i want this field (email) displayed (non editable) in the child form.

do you know if i can build this?

Thanks for your help

#1136580

Dear Steffen,

In a single Job post, you can display the "email" field value with shortcode [types field="email"][/types]
https://toolset.com/documentation/customizing-sites-using-php/functions/#email

And there isn't such a built-in feature to setup "this field (email) displayed (non editable) in the child form", in your case, I suggest you try these:
1) Create a custom email field "job-email", register it to post type "application"
2) In the child form:
a) display "job-email" field, , use "email" field as default value, and add a CSS class name "job-email", for example:

[cred_field field='job-email' force_type='field' class='form-control job-email' output='bootstrap' value='[types field="email" output="raw"][/types]']

3) click "JS Editor", setup custom JS codes to setup above field as a read-only field:

(function( $ ) {
    // javascript code here. i.e.: $(document).ready( function(){} ); 
  	$('input.job-email').attr('readonly', 'readonly');
 
})(jQuery);

Then you will be able to send the email the "email" field too

#1137009

Thanks for your help.

i will check this in the next few days...and then i´ll give you feedback in this!!

cheers

#1137354

OK, please update this thread if you still need assistance for it.

#1138270

Hey Luo,

everything works great. Also your js function. Great work!

Another question came up to this topic:
Notification Email:
I have set up an email notification and all works good except the placeholder "parents title name".
Everytime the mail goes out the placeholder is empty.

Any ideas why?

cheers and thanks

#1138798

That placeholder %%POST_PARENT_TITLE%% works for legacy(old) parent/child post type relationship, I suggest you follow our document to display the parent post title with shortcode [wpv-post-title], for example:
[wpv-post-title item="@RELATIONSHIP-SLUG.parent"]

More help:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent