Jump to content

Dependent Selects field type

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.

Share this post

Link to post
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:


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

  • Like 3

Share this post

Link to post
Share on other sites


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

Share this post

Link to post
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).

Share this post

Link to post
Share on other sites


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

Share this post

Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DxJR
      So, I've tried looking through here and Can't seem to find it. I'm trying to create a situation in the admin where:
      I have a page reference InputField. When the user chooses one of those pages, from the dropdown, a new Page reference drop down pops up with that pages children in it. I know how to do the "show only if..." thing, but How did I make it dynamically pull in a pages children? Thanks
    • By obesegiraffe
      Hi all, first time poster on the forums but long-time user of Processwire. I couldn't find this exact problem in the forums and I'm hoping it's just something simple I'm missing (first day back from vacation so I am a little brain dead). 
      I have a Select Options Field Type where the client can choose an array of numbers. If nothing is chosen, nothing is outputted onto the page. This works for most pages using this specific template. However, on just one page where I have the field set to blank, I am finding it is still outputting "0", when it actually shouldn't be outputting anything. My code:
      <?php if($page->percent_leased->has('id!=0')){ ?> <h2><?=$page->percent_leased->title?>% Leased</h2> <?php } ?> On this specific page, it is outputting "0% Leased". It's also doing something kind of weird in the database under the percent_leased field type. It's repeating the same ID of the specific problem page twice (page ID 1086) when I set it to blank. It works fine if I actually choose a number and the duplicate goes away. I've never really delved deep into the databases so maybe this is normal? 

      The weird thing is is that this is working fine on all other pages using this template. It's just this one page acting weird. FWIW, this particular site is running version 2.6.1. 
      Thanks for reading!
    • By gebeer
      Happy New Year to everyone!
      For a project that I'm working on, I needed to have dependent checkboxes on page edit forms in the admin. Just like dependent selects but for checkboxes. I couln't find anything and decided to write my first Inputfield module.
      I have only tried it on PW > 3.0. But it should also work on the 2.x branch. Would be great if some of you could try it out and give some feedback.
      You can find the module InputfieldDependentCheckboxes at github
      Here's some screenshots of the module in action and instructions on how to use it.
      ##An Inputfield for ProcessWire admin interface that handles the display of dependent checkboxes in page fields
      Sometimes we need checkboxes to depend on other checkboxes in our page edit forms. This module adds this functionality to standard page field checkboxes for 2 or more checkbox fields.

      ## Installation
      1. Copy all of the files for this module into /site/modules/InputfieldDependentCheckboxes/
      2. In your admin, go to the Modules screen and click "Refresh". Under the 'Inputfield' section, install the 'InputfieldDependentCheckboxes' module.
      3. Open Modules->Configure->InputfieldPage. Under 'Inputfield modules available for page selection' add 'DependentCheckboxes' from the select dropdown and submit

      ##Field Setup
      This inputfield extends the standard checkboxes for page fields. Therefore you need to have page fields configured already that you can extend with this Inputfield type.
      You need to have at least 2 fields of type page that have 'Checkboxes' defined as Input field type and live on the same template.
      A real world example:
      There are different types of instructors. Each instructor type can have multiple different certifications.
      For this to happen, we need 2 page fields (multiple):
      A) instructor_types: lists pages with template 'instructor_type'
      B) certifications: lists pages with template 'certification'
      The certification template needs to have the instructor_types page field to assign one or more instructor_types to a certification.
      ###Setup (link checkbox fields)
      1. Edit your page field A and go to the 'Input' Tab. Under 'Input field type' choose 'DependentCheckboxes'. Hit save. Now under 'Choose the target checkboxes field' choose the name of your field B. Hit save again.

      2. In your page field b make sure to choose a template under 'Input' Tab under 'Selectable Pages'->'Template of selectable page(s)'.

      Your fields should be setup. If you now edit a page that contains the 2 fields, the dependent checkboxes should be working. 
      EDIT: And yes, this is working for multiple dependent checkboxes, too. (I have tried it with 3 so far)
      Some notes on how the module works behind the scenes:
      - parent checkboxes (actors) that have dependent checkboxes (targets) get custom data attributes applied which contain arrays of the targets' IDs
      - some Javascript is initiated on acxtors and targets to handle the display based on the id arrays in the data attributes.
      EDIT: since this module's mention in ProcessWire Weekly it might get some more attention. I just wanted to point out that it is still in alpha state. I will continue development and more thorough testing while implementing it in an ongoing project within the next 3-5 months or so. I will eventually release a stable version then.
      If you use the module with only 2 dependent checkbox fields, it should work smoothly. There are still some quirks when using 3 or more and I need to figure out how to best resolve them. So please be patient (or jump in with ideas ).
    • By biotech
      Hello everyone,
      Brand new to PW and after few hrs loving the potential and control but hating my state of ignorance
      I understand that page hierarchy is one way to organize (categorize) content so I am trying to build Categories for use in a Blog type of content.
      So far, I have made a page called "Categories" with simple just "title" field and created children records (subcategories).

      In my 'blog' I created a field called "categories" and used it to pull records from the page above.
      However, any input field type I choose does not pull children records and only parents are shown.(i.e camping and photography)

      The only field type that is capable is "PageListSelectMultuple*" but unfortunately there is no way to prevent duplicated categories/pages to be selected.
      Checkboxes would be my preference but not sure how to go about it all or what am I missing in the setup.
      Thank you for your time.
      O.T. but where would I find 'skyscraper site profile' to download?
  • Create New...