Jump to content

Dependent Selects field type


gebeer
 Share

Recommended Posts

In the thread for the Select Multiple Transfer module Ryan mentions that he used "dependent selects" for his introduction video:

Note that this video is showing this module in combination with field dependencies and dependent selects (something else brewing for 2.4 but not yet committed to dev

I searched the dev code and the forum up and down but can't seem to find this fieldtype.

Has development been discontinued?

I would really love to see that fieldtype in PW and would even be happy to pay for it if it was published as a pro field.

I switched over to PW from Joomla/Seblod and they have a fieldtype called "Select Dynamic Cascade" that does just that.

Link to comment
Share on other sites

I might be missing what you are actually after, but do you know about using something like this for the selector value for a page field:

parent=page.otherpagefield

That allows for ajax population of one select based on the selected value of the otherpagefield

  • Like 3
Link to comment
Share on other sites

@adrian

Thanks for the pointer. I had already found that here. But as Soma points out it only works for pages that are nested under the same parent.

I would need something like this for page select fields that live under different parents in the page tree.

My use case:

1. parent countries with list of all countries

2. parent destinations, each destination gets assigned one country through "countries" pages asm select field.

3. parent tours, each tour gets assigned 1 or more countries through "countries" field and 1 or more destinations from "destinations" pages asm select field

In tours form, when countries are selected I want to filter the destinations field to only show destinations of the previously chosen countries.

Destinations cannot live under countries because I need them under a separate parent where the user can add destinations easily without having to drill through the 249 available countries and search for the right one where they want to add their destinations under.

What I think would work in theory:
An inputfield type that lets you define which select fields in a template depend on each other and what the hierarchy of those fields is. This inputfield type adds the JS logic to the template form that will get the option values for the dependent select fields via AJAX call and fills them. The PHP of the inputfield type holds the logic to retrieve the right pages for the AJAX request.

There are jQuery plugins like this or this available that could be used. Or the JS that is already there when using selector "parent=page.otherpagefield".

  • Like 1
Link to comment
Share on other sites

NO need to post 20 post about the same all over the forum. There's misunderstanding that this is not a fieldtype but a technique you can use in custom selector for page select, so it is dependent on the selected value of another page select on currently edited page. This is in PW since a long time and not documented. But once you set it up it's using ajax to populate the selects, so is something that requires backend page editor context. This isn't something you can use on front-end just so, or form-builder (AFAIK).

Link to comment
Share on other sites

@Soma

I am sorry, didn't mean to flood the forum with this. Was just exited about the whole thing and that maybe made me go a bit far...

Your proposed solution for setup and custom selector to get this working with pages that don't share the same tree is great. Very much appreciated.

I put something together quickly to have the same functionality in a frontend form with the help of a jQuery plugin.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...