Viewing 4 reply threads
  • Author
    Posts
    • #3969
      envmar
      Member

      Hi. Sorry if my terminology is off or this question has come up. I haven’t found anything yet.

      I’m working on a CPT form that I’m attempting to use a hierarchical custom taxonomy that uses the parent terms to populate one field and the children of the selected parent to populate a second field. So, for example, in the form you would have:

      Select Field: vehicle_make (options are populated by get_terms from make_model taxonomy and only parent terms)

      Select Field: vehicle_model (options should be dynamically populated using get_terms that are children of the ID value in vehicle_make field).

      So, I’ll need Piklist to either push or get the option ID value when selecting vehicle_make and then re-build the select/options for vehicle_model with it.

      All examples of conditions I’ve found are hard coded. Is it possible with Piklist to call get_terms again the form has been rendered? Could this be done with an onChange attribute or something like that?

      Hope that question wasn’t too muddled.

    • #3975
      Steve
      Keymaster

      @envmar– Welcome to the Piklist community!

      Piklist can do this with a page save/load. Once you save the form, pull the data from vehicle_make, and use it to populate vehicle_model. Hope that helps.

    • #3976
      envmar
      Member

      Hey Steve, thanks for the welcome and the quick reply.

      Are you saying that with the page save/load you mean when physically entering the data hit the save button after that field? Or, are you suggesting that onChange I do something like an ajax call to save?

      I’m hoping for a code based solution and have just been mulling around ideas. I’m new to Piklist so every idea requires a lot of hunting. A few thoughts I had:

      1) Add data attributes to the option field and use jQuery to hide those in vehicle_model select that don’t have the parent ID of vehicle_make. It looks like I’ll have to hack the code for that though, as I don’t believe we have the option to add attributes with the Piklist metabox fields?

      2) Possibly writing a custom filter? I haven’t read anything about extending Piklist yet so I’m not sure how hacky I’d have to get with that.

      3) Breaking up the make_model taxonomy into two separate taxonomies with some type of relationship via custom fields in them. Then I’d just using them in the standard sidebar like tags/categories. Not sure what kind of problems that would cause down the line though.

      Thanks again Steve. Hoping I can figure something out. This is my first foray into Piklist and I’m planning on using this as a springboard to several other projects.

    • #3979
      Steve
      Keymaster

      The easiest way is physically entering the data hit the save button and then pull the data into the other field.

      You can add attributes to any Piklist field, using the attributes parameter, including onchange.

      Another solution… that’s a real hack, is to dynamically create child field for ALL the parent terms, and only show the one you want when the parent is selected. Obviously, if you have tons of terms this can lead to performance issues.

    • #8257
      strarsis
      Participant

      Is it planned to add AJAX support to Piklist? This would be a great feature in admin area.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.