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

Docs (README.md): update documentation for conditional logic #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,49 @@ To reference a field in conditional logic when inside a nested sub field (for ex
}
```

To reference a field in conditional logic when the field you are referencing is inside a nested sub field (for example, in a group), the `fieldPath` must have the parent and child field. The `fieldPath` should look like this:
```
fieldParent_fieldChild
```
This is how ACF Field Group Composer builds keys under the hood. By setting `fieldPath` this way, you are directly referencing the key of the field you want.
For example:
```json
{
"label": "Content Options",
"name": "contentOptions",
"type": "group",
"sub_fields": [
{
"label": "Has Content",
"name": "hasContent",
"type": "true_false"
},
]
},
{
"label": "Content Group",
"name": "contentGroup",
"type": "group",
"sub_fields": [
{
"label": "Content",
"name": "contentHtml",
"type": "wysiwyg",
"conditional_logic": [
[
{
"fieldPath": "contentOptions_hasContent",
"operator": "==",
"value": "1"
}
]
]
}
]
}
```
> Becuase keys are built using the snake case, naming your fields using snake case could lead to issues. If in this previous example hasContent was named has_content, there could be issues with constructing the keys.

## API

### ACFComposer\ACFComposer (class)
Expand Down