Support

Account

Home Forums General Issues Relationship fields filtering over next relation

Solving

Relationship fields filtering over next relation

    • mmn

    • December 12, 2013 at 11:12 pm

    Hi, ‘m planning to develop a system based on custom_post_type of 3 base kind:

    – Event;
    – Appointment;
    – Person;

    Event is my base value.
    Each Appointment can have max 1 relation with an Event.
    Person can have only 1 relation to Event but several appointments.

    I’m wondering to create a custom structure for Person where:

    – I select the base Event as Relationship;
    – Once I did it the next field of Appointments will be filtered using the Event selected (looking at the relation inside the custom_post Appointment that links Event & Appointment);

    This is what I’m looking for, but atm I haven’t figured out yet how to do this and if I can do this using ACF.

    Do you have any hint? Suggestion to reach my goal?

    Thanks!

    • Elliot

    • December 13, 2013 at 10:19 am

    Hi @mmn

    Thanks for the question.

    Lets assume you are on the edit page for a person, and you want to select 1 event and then 1 Appointment.

    You can use ACF to create the Event field (post object field). This will show all Events posts and allow 1 selection.

    Next, you need to update / populate the Appointment select field. I would create this as a select field with no choices, and rely on JS to populate is after an Event has been selected.

    You could write a jQuery event for the Appointment Change, and then get the Appointments via AJAX, then just update the Appointments select DOM object with the results.

    Good luck!

    Thanks
    E

    • mmn

    • December 13, 2013 at 7:12 pm

    Hi @elliot, can I ask you how to create a hook for populating the select field? I’d assume that the best tut that explain my needs is this one: http://www.advancedcustomfields.com/resources/tutorials/dynamically-populate-a-select-fields-choices/

    Is it correct?

    • Elliot

    • December 15, 2013 at 5:36 pm

    Hi @mmn

    Yes. The link you have posted is a good tutorial to follow if you want to populate a select field’s choices dynamically. Please note that this will not create any jQuery / AJAX functionality, and will only work on page load.

    Thanks
    E

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.