Sauter la navigation

[Résolu] Display parent details as part of child post and open cred form when clicked

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: I would like to display information from two different grandparent post types on a parent post. I would also like to create a Form that creates child posts, and insert a link to that Form on the parent post so that the parent is automatically selected.

Solution: Create a View of Requirement CPTs. In the Loop, you can insert the post title shortcode to display the related Company name. Click "Fields and Views", then "Post title", and you will be shown a popup. Click the "Post Selection" tab, then choose "A post related to the current post, set by a Types relationship". Next, select the Company post in your Company > Requirement post relationship.

Create the new Submission Post Form and insert it in a custom Page. Then return to the View of Requirements editor and use the Toolset Forms button above the Loop Editor to insert a "Create Child Post Link". Select the Page containing the Submission Post Form, and a link will be automatically inserted for you.

When Users click the link, they will be directed to the Page containing the new Submission Form. If you want to hide the parent select field in the Form, you can use CSS in the Form editor.

<div style="display:none;">
[cred_field field="@relationship-slug.parent" class="form-control" output="bootstrap" select_text="--- not set ---"]
</div>

Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

This support ticket is created Il y a 6 années. 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par AndreG3332 Il y a 6 années.

Assisté par: Christian Cox.

Auteur
Publications
#1154723

My structure at the moment is as follow:

The () denotes the relationship down the order of the list

A Company CPT (one)
a Requirements CPT (many) (one)
a Submissions CPT(many)
____________________
Document master list CPT (One)
requirements CPT (many) (One)
submissions CPT (Many)
_____________________
They are in one to many relationships from top to bottom. IE Company is the grandparent of Submissions.
I need to create a view with the requirement CPT but it must include "The Company" post title and the docuement post title in the table.

Ie field in table:
Post title (Requirements)
Year (requirements)
Company name (Company CPT title field)
Document Name (Document master list Cpt Title field)

The "post title requirements" must be clickable to open a cred form with the required document entry where the document can then be submitted via the submissions CPT.
All the field will use the post title as the reference point

I can get the post title and the year in the list but not the parent details and I have to have it for filtering purposes.

Could please assist with the flow of the above?

#1154891
post-selection.png

I need to create a view with the requirement CPT but it must include "The Company" post title and the docuement post title in the table.
It sounds like you should create a View of Requirement CPTs. In the Loop, you can insert the post title shortcode to display the related Company name. Click "Fields and Views", then "Post title", and you will be shown a popup like the one in post-selection.png. Click the "Post Selection" tab, then choose "A post related to the current post, set by a Types relationship". Next, select the Company post in your Company > Requirement post relationship.

The "post title requirements" must be clickable to open a cred form with the required document entry where the document can then be submitted via the submissions CPT.
It sounds like you want to click a link in the View of Requirements that will allow you to create a new Submission post. First, create the new Submission Post Form and insert it in a custom Page. Then return to the View of Requirements editor and use the Toolset Forms button above the Loop Editor to insert a "Create Child Post Link". Select the Page containing the Submission Post Form, and a link will be automatically inserted for you.

When Users click the link, they will be directed to the Page containing the new Submission Form. If you want to hide the parent select field in the Form, you can use CSS in the Form editor like this:

<div style="display:none;">
[cred_field field="@relationship-slug.parent" class="form-control" output="bootstrap" select_text="--- not set ---"]
</div>

All the field will use the post title as the reference point
Sorry, I do not understand. Can you explain in more detail?

#1155327

I have done the "view of requirements" with the relational fields and it was working 100%, Thx

The next step was to create the "submission post"form and add that to the "view of the requirements". It is working in the sense that it opens up the form when you click, and you can upload the document but it does not connect the document to the required field.

Select the Page containing the Submission Post Form, and a link will be automatically inserted for you.</I>
I do not see this link in the submissions page
lien caché

This is the loop editor code for the requirements view

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<table width="100%">
		<thead>
			<tr>
				<th>[wpv-heading name="post-title"]Post title[/wpv-heading]</th>
              	<th>Upload</th>	
				<th>[wpv-heading name="types-field-year"]Year[/wpv-heading]</th>
              	<th>[wpv-heading name="post-title"]Post title[/wpv-heading]</th>
				<th>[wpv-heading name="post-title"]Post title[/wpv-heading]</th>
			</tr>
		</thead>
		<tbody class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<tr>
				[wpv-post-body view_template="Loop item in Requirements views"]
			</tr>
		</wpv-loop>
		</tbody>
	</table>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

and this is the code for the template for this view

<td>[wpv-post-title]</td>
<td> [cred_child_link_form form='177' text='Upload here' target='_self']</td> 
<td>[types field="year"][/types]</td>
<td>[wpv-post-title item="@customer-requirement.parent"]</td>
<td>[wpv-post-title item="@document-master-list-requirement.parent"]</td>

This is the code for the content for submissions form

[credform]
	[cred_field field="form_messages" class="alert alert-warning"]
	<div class="form-group">
		<label>Submission Title</label>
		[cred_field field="post_title" class="form-control" output="bootstrap"]
	</div>
	<div class="form-group">
		<label>Date first uploaded</label>
		[cred_field field="date-first-uploaded" force_type="field" class="form-control" output="bootstrap"]
	</div>
	<div class="form-group">
		<label>Upload document</label>
		[cred_field field="upload-document" force_type="field" class="form-control" output="bootstrap"]
	</div>
	<div class="form-group">
		<label>Status</label>
		[cred_field field="status" force_type="field" class="form-control" output="bootstrap"]
	</div>
	[cred_field field="form_submit" output="bootstrap" value="Submit" class="btn btn-primary btn-lg"]
[/credform]

#1155419

My issue is resolved now. Thank you!