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
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
Thanks for your help.
i will check this in the next few days...and then i´ll give you feedback in this!!
cheers
OK, please update this thread if you still need assistance for it.
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
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