I have two custom post types, Project and Person.
Project entries have two custom fields of the Relationship type:
1. PROJECT LEAD
2. OTHER RELATED PEOPLE
Both fields are restricted to the Person post type.
What I want to do is hide values in each field that have been selected in the other field.
For example, if Jane is already selected as PROJECT LEAD, I want to remove Jane from the options for OTHER RELATED PEOPLE.
Is this possible via the available ACF filters?
Exactly what I’m looking for but for a soccer team 😉 . I’m investigating on this and check some solutions.
It is not possible on php side because there is no hook when you add/remove an item in one field.
Seems to be possible using JS API… but I need to pass items list (available in PHP)
What I’ll try :
managing add/remove hook using JS API
launch an ajax request that manage the selected list (as global) and add/remove items depending on the selection.
Should do the trick but it seems hi level dev…
Thank you, John and Christian.
I just want to make the lifes of my content editors a little bit easier but, other than that, it is not an issue for me now. I can deal with possible double selections from the templates.
The new JS API looks good! I’ll try to have a proper look when I find some time.
1st of all, sorry for the late reply.
Yes sure I’ve done some code that allows to manage group of fields in order to add the possibility to make some value inclusion, exclusion.
By adding a specific class to some fields, you can :
– group fields
– insert value from a group
– exclude value from a group
– Mix all this.
It is a JS lib (but with some jQuery code, not 100% migrated to vanilla js ).
It is running everyday without any problem (in my site context) without enhancements since more than one year.
You can find it here : https://github.com/chdenat/acf-xtend
Feel free to contact me for further explanation.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!