Skip Navigation

[Resolved] CRED form field relationships

This support ticket is created 4 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 11 replies, has 2 voices.

Last updated by Luo Yang 4 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#1403267

I have several post reference fields that I am using in multiple custom post types to allow users to easily access newly created data from other custom post types. The problem I am now seeing is that the relationship is not quite right. For example:

User creates 'Project' in projects CPT. : Widget Project 1
Then they go to 'Version' CPT: and add a version number. They can find the project in the reference field no problem.
Now here is where things become more complicated:
User creates a new 'Build' using the build CPT. In the post reference fields (for projects, and versions) they will see all the previously created posts. So here is what I would like to do (if possible).
User opens create new build form, they use the post reference field to select the correct project. Then they use the next post reference field to select a version. But that version has to be related to the project. For example, there could be ten different version '1' in the reference field. So they should only see the '1' related to the project they selected.
A similar thing needs to happen for other forms.

Thanks!

#1403599

Hello,

I assume we are talking about this case:
Three post types:
- Project
- Build
- Version

There is a custom field group with post type "Version", with one post reference field:
- related Project post 1

There is a custom field group with post type "Build", with two post reference fields:
- related Project post 2
- related Version post

You are going to do this insider post form for creating "Build" post
When user select one option in field "related Project post 2", limit the option "related Version post" according to "elated Project post 1" field setting.

If it is, there isn't such kind of built-in feature, you might consider child post form, for example:
1) Create a post form for creating "Build" post
2) In single "Version" post, display the form link for creating "Build" post, see our document:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

And you can preset the "related Version post" field value in post form by URL parameters, see our document:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
urlparam. Optional. A URL parameter to set default value.

#1404769

I'm completely confused. I added the relationship fields. But I don't understand what to do next.

#1405043

Please provide a test site with the same problem, also point out the problem page URL and form URL, I can setup a demo for you.

#1405325

Thanks for the details, I can log into your website.

I assume we are talking about post form "Create New Builds", since you did not point out the URL where I can test it, so I have done below modifications in your website:
1) Create a new version post:
hidden link
in field "Version Select Project", relate with a project post.

2) In post content, setup the HTML link as below:

<a href="[wpv-post-url item="42"]?parent_version_id=[wpv-post-id]&parent_project_id=[wpv-post-id item="@module-select-project.parent"]" target="_self rel="noopener noreferrer">Create new child build</a>

It will be able to pass two URL parameters to target page:
- parent_version_id, the version post ID
- parent_project_id, the project post ID

3) Edit the post form: Create New Builds
hidden link

Edit both post relationship fields:
- Build Select Project, setup the option "Set default value from an URL parameter" as: parent_project_id
- Build Related Version,setup the option "Set default value from an URL parameter" as: parent_version_id

So both fields will accept the URL parameter values as default values.

You can test it here:
hidden link

Click link "Create new child build", it will redirect you to URL:
hidden link

You should be able to see both relationship fields are preselected.

You can use CSS codes to hide those two elationship fields, see the document I mentioned above:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/
section "Creating forms when a parent post is preselected"

#1411795

Still confused.

I went to the link you provided - hidden link and it opened a page. There was a link to a form which had all the fields populated. But if I select items in there they do not adjust based upon the selections. For example:

If I select: My Project Dev Test 4 ( I should only see '1' under Versions). If I change the project to 'A Test Project 3' I should only see '35' under Versions.

So any form that has dropdown options needs these options to relate to the options that come before.

#1412579

The credentials you provided above is not valid any more:
https://toolset.com/forums/topic/cred-form-field-relationships/#post-1405177
I get this error:
Error: Invalid Password.

Please check it

#1413365

Yes, That is true. Please provde the private form so I can update your password. I had to provide access to Christian as well.

#1414075

I have enabled the private message box again, please provide the credentials in it, thanks

#1414401

Thanks for the details, as I mentioned in my first answer:
https://toolset.com/forums/topic/cred-form-field-relationships/#post-1403599
There isn't such kind of built-in feature within Toolset Forms plugin, so I provided the workaround.

In simple words:
Those relationships fields can not adjust automatically, you can only populate the default value with URL parameters.

Hope it is clear.

#1414999

That isn't a workaround.

#1415565

As I mentioned above, there isn't such kind of built-in feature within Toolset Forms plugin as you want:
Those relationships fields adjust options automatically in Toolset Forms

You might add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Or developers will evaluate it.