Home Forums General Issues Conditional logic on Post Object


Conditional logic on Post Object

  • Hello,
    I’m trying to create a conditional field based upon whether a specific previous Post Object has been selected.

    For example, imagine I have a post type called Project Types which contains posts called Project Type 1, and Project Type 2.

    Within ACF I would have a Post Object field to populate a list of all the Project Types posts. However, I’d like to show an additional field, only when Project Type 2 is selected.

    Would this be possible?

  • It is doable. I believe you need the id of each project you want to be different. Once you have this, you set the conditional rules on the extra fields you want to come up with for your Post Object field to have a value greater than 1 below your ID and less than 1 more than your id. So if you had a post with an ID of 151 it would look like this
    screenshot of post object conditional

  • I did some digging and testing. I attempted to add “Selection is equal to” to the conditional logic on the post object field and I understand why it was left off.

    When selecting is equal to ACF inserts a select field that has the choices set for check box, radio, select fields, etc.

    When selecting > of < ACF inserts a number field.

    As it stands, to use == there would need to be a whole lot of additional AJAX done in order to figure out what the “choices” could be.

    I don’t know if this helps to explain it to others.

    Since ACF does not know what the choices can be it cannot insert the select field. Adding < and > for a post object field was possible without a complete rewrite of the code involved. Adding = would require a complete rewrite of all the code involved for it with different things happening based on the the type of field the condition is set for. The only options added were those where the options that already existed would simply work without modification.

    While using 2 items > and < to get a specific number is not pretty, it does work. More than likely when Elliot works out all of the issues with gooberbug we might see something better.

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

The topic ‘Conditional logic on Post Object’ is closed to new replies.