Skip Navigation

[Resuelto] Changing select inputs depending on form entry

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.

Our next available supporter will start replying to tickets in about 5.72 hours from now. Thank you for your understanding.

This topic contains 2 respuestas, has 2 mensajes.

Last updated by Tim Elliott hace 2 años.

Assigned support staff: Luo Yang.

Autor
Mensajes
#1390415

Tell us what you are trying to do?

I'm trying to do something similar to hidden link
In this form the "Select Campus" and "Select Course" boxes have no options until you select a School. Then they are populated with the relevant Campuses / Courses.

I have 3 post types, Schools, Courses and Reviews.
There are relationships between them as follows:
Schools >> Courses (one-to-many)
Schools >> Reviews (one-to-many)
Courses >> Reviews (one-to-many)

Users can write a review, and when that review post is created the form creates a relationship to both the school and the course.

I have a generic page where they can write these reviews with a post form. The first 2 fields in the form are selects for the School and the course.

As it stands these fields are populated with all the schools and all the courses on the site.

Ideally I'd like it to work so that when they select a school the options on the course select are then limited to only courses in a a relationship with the selected school.

I'm not sure if I can do this with Forms, whether I can do it with a bit of javascript, or whether I can somehow fake it using a view outside my form.

Any guidance much appreciated.

#1390779

Luo Yang
Supporter

Languages: Inglés (English ) Chino simplificado (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hello,

Thanks for the details.
There isn't such kind of built-in feature within Toolset Forms plugin.
And according to our support policy, we don't provide custom codes support.
https://toolset.com/toolset-support-policy/

Here is my suggestion, you can try these:

1) Create a post form for creating "Review" post, for example "my-review-form"

2) Create a post view with custom search form
- Query Courses post
- Filter by parent School post
https://toolset.com/documentation/user-guides/front-page-filters/#2-6-filtering-posts-by-their-ancestors
- In view's loop display Courses post information + "my-review-form" form link.

Put above post view into a page, so your user can search the Courses posts by parent School, and click child form link to create the review post.

More help:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/#creating-forms-when-a-parent-post-is-preselected
Creating forms when a parent post is preselected

#1394135

I kind of made this work though it's not as smooth as the example I gave, and it took a lot of work. Maybe it's something Toolset could think about adding as a feature in future.

My solution was as follows:
I used a view showing courses. I use a Toolset filter to filter by school. I used the output of the loop to create another filter showing the courses.

Below this is a form which includes hidden fields for the school ID and course ID.
I then use jquery to update the values of the hidden fields on page load and on filter changes, so when the form is submitted the values of those fields match what's in the view filters.

It's not perfect but hopefully good enough.