Dependency

Introduction

The Gravity Forms Settings API allows fields or sections to be shown or hidden based on the value of another field. You can specify a field name, a function, or a field name with specific values. If only a field name is given, the field is checked for any value.

You can enable live dependency checking by setting live => true in your dependency configuration. This will show or hide the field immediately as the dependent field’s value changes. Without this setting, you may need to trigger a page reload for the dependency to be re-evaluated.

Field name:

'dependency' => 'the_field_to_check',

Function to run:

'dependency' => array( $this, 'check_textfield_dependency' ),

Field name with an array of values:

'dependency' => array( 'field' => 'mytextfield_name', 'values' => array( 'test', 'test2' ) ),

Field name with live checking enabled:

'dependency' => array( 'field' => 'mytextfield_name', 'values' => array( 'test', 'test2' ), 'live' => true ),