- This topic has 4 replies, 3 voices, and was last updated 4 years, 8 months ago by
strarsis.
-
AuthorPosts
-
-
July 7, 2015 at 4:05 am #3969
envmarMemberHi. 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.
-
July 7, 2015 at 10:58 am #3975
-
July 8, 2015 at 1:09 am #3976
envmarMemberHey 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.
-
July 8, 2015 at 1:23 pm #3979
SteveKeymasterThe 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.
-
May 24, 2017 at 12:48 am #8257
strarsisParticipantIs it planned to add AJAX support to Piklist? This would be a great feature in admin area.
-
-
AuthorPosts
- You must be logged in to reply to this topic.