Conditional Logic Object

Introduction

Conditional Logic, when applied to the form or page button or to any field, controls the visibility of that element based on a choice selected or value entered by the user in other fields on the form. It can also be used to determine if a notification, confirmation or add-on feed should be used.

array(
	'conditionalLogic' => array(
		'actionType' => 'show',
		'logicType'  => 'all',
		'rules'      => array(
			array(
				'fieldId'  => 2,
				'operator' => 'is',
				'value'    => 'Second Choice',
			),
		)
	),
);

Usage

// returns the conditional logic rules for the form button
$rules = rgars( $form, 'button/conditionalLogic/rules' );

// returns the conditional logic rules for the field
$rules = rgar( $field->conditionalLogic, 'rules' );

// returns the conditional logic rules for the feed
$rules = rgars( $feed, 'meta/feed_condition_conditional_logic_object/conditionalLogic/rules' );

Properties

PropTypeDescription
actionTypestringThe type of action the conditional logic will perform.
Possible values:
show: Displays the field when the rules match and hides the field when the rules do not match.
hide: Hides the field when the rules match and displays the field when the rules match.
logicTypestringDetermines how to the rules should be evaluated.
Possible values:
any: Evaluates the conditional logic to true if any of the rules match. More specifically, will OR the rules together (i.e. rule1 || rule2 || rule3).
all: Evaluates the conditional logic to true if all rules match. More specifically, will AND the rules together (i.e. rule1 && rule2 && rule3).
rulesarrayAn indexed array containing associative arrays for each rule.

Rule

PropTypeDescription
fieldIdinteger|stringThe ID of the form field, entry property, or entry meta that will have it’s value compared to the rule value.
operatorstringThe operator to be used when evaluating this rule.
Possible values:
is: Evaluates this rule to true when the value of the field specified by fieldId is equal to value.
isnot: Evaluates this rule to true when the value of the field specified by fieldId is not equal to value.
<: Evaluates this rule to true when the value of the field specified by fieldId is less than value.
>: Evaluates this rule to true when the value of the field specified by fieldId is greather than value.
contains: Evaluates this rule to true when the value of the field specified by fieldId contains value.
starts_with: Evaluates this rule to true when the value of the field specified by fieldId starts with value.
ends_with: Evaluates this rule to true when the value of the field specified by fieldId ends with value.
valuestring|integer|floatThe value to be compared with the value of the field specified by fieldId.