• Resolved arturofez

    (@arturofez)


    Hi!

    I’m trying to show a field in a CPT based on the value of another relationship field (which is linked to a custom taxonomy. I am using a relationship field rather than a taxonomy connection because it needs to be a single select).

    The parameters for the conditional logic I’m using are:

    • Show
    • all
    • relationship_name
    • is (id/value)

    I have tried the ID, the slug and the name, with and without quotation marks, but nothing seems to work as the field is never shown.

    I’m using Pods 3.0.3

    Thanks in advance

    • This topic was modified 1 year, 5 months ago by arturofez.
    • This topic was modified 1 year, 5 months ago by arturofez.
    • This topic was modified 1 year, 5 months ago by arturofez.
Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    To confirm — the you were entering the term_id you want to filter by for the value, correct?

    I can confirm on my end that this is how it is working with the one I just tested myself.

    Thread Starter arturofez

    (@arturofez)

    That’s right, I’m using the term_id of the taxonomy term:

    I’m using single select and radio buttons as display options in the field used for filtering.

    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    That exact usage works for my case on a CPT with a relationship field to a taxonomy.

    The next step may be to try opening your browser console and set it to show verbose/debug logs. Then go to the screen with your field that should be showing. Clear the logs to ensure nothing else is showing up for our test here.

    Then try changing the value to a different term and then back to that term with the ID 78. Take a look at the logs and perhaps provide what that says.

    Here’s an example after I changed the value of my taxonomy test field to the term (ID: 88) which is what my conditional logic field is set to show on. Then right after that I switch to a different one.

    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 Conditional logic: enabled
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 {fieldName: 'test_field_copy', conditionalLogic: {…}, allPodValues: {…}}
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 Conditional logic: validateConditionalValue doesValueMatch
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 {fieldName: 'test_field_copy', fieldNameToTest: 'related_category_copy', doesValueMatch: true, compare: '=', ruleValue: '88',?…}
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 Conditional logic: enabled
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 {fieldName: 'test_field_copy', conditionalLogic: {…}, allPodValues: {…}}
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 Conditional logic: validateConditionalValue doesValueMatch
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 {fieldName: 'test_field_copy', fieldNameToTest: 'related_category_copy', doesValueMatch: false, compare: '=', ruleValue: '88',?…}
    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    You might want to “click” to expand some of those objects there for additional debug info that will copy/paste into this forum reply.

    Here’s an example of them expanded for my reply:

    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 Conditional logic: enabled
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 {fieldName: 'test_field_copy', conditionalLogic: {…}, allPodValues: {…}}allPodValues: {publication_date: '1960-06-01', genre: 'political-philosophy', language: 'greek', country: 'GR', book_author: Array(1),?…}conditionalLogic: {action: 'show', logic: 'any', rules: Array(1)}fieldName: "test_field_copy"Prototype: Object
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 Conditional logic: validateConditionalValue doesValueMatch
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 {fieldName: 'test_field_copy', fieldNameToTest: 'related_category_copy', doesValueMatch: true, compare: '=', ruleValue: '88',?…}compare: "="doesValueMatch: truefieldName: "test_field_copy"fieldNameToTest: "related_category_copy"ruleValue: "88"valueToTest: "88"Prototype: Object
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 Conditional logic: enabled
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 {fieldName: 'test_field_copy', conditionalLogic: {…}, allPodValues: {…}}allPodValues: {publication_date: '1960-06-01', genre: 'political-philosophy', language: 'greek', country: 'GR', book_author: Array(1),?…}conditionalLogic: {action: 'show', logic: 'any', rules: Array(1)}fieldName: "test_field_copy"Prototype: Object
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 Conditional logic: validateConditionalValue doesValueMatch
    pods-dfv.min.js?ver=0d4d9fb35b69e492260e:1 {fieldName: 'test_field_copy', fieldNameToTest: 'related_category_copy', doesValueMatch: false, compare: '=', ruleValue: '88',?…}compare: "="doesValueMatch: falsefieldName: "test_field_copy"fieldNameToTest: "related_category_copy"ruleValue: "88"valueToTest: "89"Prototype: Object
    Thread Starter arturofez

    (@arturofez)

    Okey, I think I see the error, but I’m not sure why it’s happening. Comparison operator is ‘>’ in the console, even though it’s supposed to be set to ‘is’ (‘=’).

    When I choose another value, which is greater than 78, the field is displayed!

    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    Can you go into your fields and select a different comparison option and then switch it back to “is (id/value)” there? Then save the field and go to the form to see what comparison it uses. I’m curious to see if there might be something going on there somehow.

    Thread Starter arturofez

    (@arturofez)

    That’s exactly what I just did! And it works now. Thank you.

    Do you know what could be happening?

    Edit: Okay, it works, but only when I change the value and then select it back. When it loads, the field still does not appear

    • This reply was modified 1 year, 5 months ago by arturofez.
    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    To clarify — you said it works when you change the value and set it back — is that in the form itself or when editing the Pod Field configuration?

    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    I can confirm that there seems to be a separate issue here with initial load of the screen, I’m looking into that.

    Thread Starter arturofez

    (@arturofez)

    Yes, the issue occurs during the initial load when editing the CPT instances (post.php?post=1234&action=edit)

    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    Fixed in Pods 3.0.5, no ETA on release but it may go out tomorrow unless I find other things to address.

    Thread Starter arturofez

    (@arturofez)

    I just installed Pods 3.0.5, and it works now! Thanks.

    Some follow-up questions:

    • When the field is required, I can’t hide it because it shows a required error upon saving even when it is hidden. Is this the expected behavior?
    • Will it be possible to apply conditional logic to group of fields in a pod?

    Perhaps for a new feature or enhancement? Should I open an issue on GitHub?

    Thank you again, the conditional logic feature is fenomenal!

    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    Required fields are not fully bypassed by conditional logic right now, they don’t really talk to each other at the moment in the code so that connection needs to be developed.

    As for conditional logic per group, that requires rewriting our meta box usage and other implementations.

    Both those things will take a bit of React work and we don’t have a dedicated React developer at the moment as they just got hired at PayPal ??

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Conditional logic with relationship field’ is closed to new replies.