Conditional logic
Conditional logic shows or hides a field while someone fills in the form, based on the values of other fields. It keeps forms short: a book's Price only needs to appear when Free ebook is switched off.
Setting it up
Open a field and go to its Conditional Logic tab. Choose Show if or Hide if, then add rules that compare other fields on the same form.
Rules come in groups. Inside a group, choose Match all conditions or Match any conditions. With several groups, choose Match all groups or Match any group. Most fields need a single rule.
What you can compare
The comparisons on offer depend on the field you're testing:
| Source field | Comparisons |
|---|---|
| Text fields | Is, Is not, Contains, Does not contain, Starts with, Ends with |
| Numbers and sliders | Equals, Not equals, Greater than, Less than (each also "or equal"), Between |
| Switcher | Is enabled, Is disabled |
| Single choice (Select, Radio, Button Group) | Is, Is not, Is any of, Is none of |
| Multiple choice (Multiselect, Checkboxes) | Contains, Does not contain, Contains any of, Contains all of |
| Dates | Is before, Is after, Is on, Between |
| Relations | Is empty, Is not empty |
Every type except Switcher also offers Is empty and Is not empty.
A Date range or Range slider can be tested on its Start or its End. Layout fields such as headings store nothing, so they can't be used as sources.
Sections and tabs
Conditional logic on a section or tabs shows or hides every field they hold, which saves repeating the same rule on each field. A field inside a section can still have rules of its own; it shows only when both it and its section do.
A section doesn't change which fields a rule can see. A field in one section can depend on a field in another, or on one outside any section. A section can't depend on a field it holds.
What hiding does to values
Hiding a field doesn't delete anything. A hidden field is simply left out of the save, so whatever was stored before stays in the database, and showing the field again brings the old value back.
Hidden fields are also skipped by validation, so a hidden field never stops a save.
Limits
- A field can't depend on itself, directly or through a chain of other fields, including the section it sits in. The editor flags a loop so you can break it.
- Rules only see fields on the same form. To decide which entries get a fieldset at all, use Location conditions.
- A Taxonomy field that uses the Native WordPress metabox mode is edited in WordPress's own box, where conditional logic doesn't run.
- Inside a Repeater or Group, rules can refer to sibling fields in the same row.
Technical details for LLMs
- Shape:
conditional_logic: { enabled: true, action: "show"|"hide", group_match: "any"|"all" (default any), groups: [ { match: "all"|"any" (default all), rules: [ { field, operator, value? } ] } ] }.enabledmust betrueor the logic is ignored. - Operators by profile: text
equals,not_equals,contains,not_contains,starts_with,ends_with; numbereq,neq,gt,gte,lt,lte,between(range value); booleanis_true,is_false; choiceequals,not_equals,is_any_of,is_none_of; setcontains,not_contains,contains_any,contains_all; datebefore,after,on,between; relation onlyis_empty,is_not_empty. All but boolean also takeis_empty,is_not_empty. A field type's profile is invx-framework/get-field-types. - Evaluation: client-side live in the editor, and again server-side on save (
compute_visibilityover the submitted values). Hidden fields: no validation, no write, no delete. - Range sources address
start/endsub-values. Layout types (ui_*) are never sources. Cycles are flagged in the editor; at runtime a field caught in a cycle is treated as visible. - Containers:
ui_section/ui_tabsare evaluated in the scope they sit in, and their fields join that scope (paths never name the container). Visibility of a field = its own logic AND every container it sits in. A rule whose source sits in a hidden container fails. A container's rule naming a field it holds is refused on save; a field-to-container edge counts toward cycle detection. - Extension filters:
vxframework/fieldsets/condition_operators,condition_profiles,condition_compare.