Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example with conditional logic #25

Open
rguttersohn opened this issue Mar 28, 2023 · 2 comments
Open

Add example with conditional logic #25

rguttersohn opened this issue Mar 28, 2023 · 2 comments

Comments

@rguttersohn
Copy link

Not sure if I am missing this somewhere, but I can't seem to figure out how to implement conditional logic for a field. I tried:

'conditional_logic' => [ 'include_call_to_action', '==', 0],

and:

[ 'include_call_to_action' => 1],

Neither is working. It would be great to have an example that uses conditional logic.

@aitormendez
Copy link

When you have doubts of this type, a good practice is to generate the field with the graphical interface and then export the PHP with the ACF tool. So you can see what the notation is like. Here is an example of conditional logic.

                'conditional_logic' => [
                    [
                        [
                            'field' => 'single_project_type',
                            'operator' => '==',
                            'value' => 'image',
                        ]
                    ]
                ],

@rguttersohn
Copy link
Author

That's a great idea. Didn't think of that. I wonder if that tip should be at the top as a catch all? I can make a PR and add it if it seems worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants