Skip to main content

Gravity_Forms\Gravity_Forms\Form_Display\State\State_Handler

Class State_Handler.

Used when creating the value for the hidden state input and validating the state during form submission.

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:18

Details

  • Kind: class
  • Namespace: Gravity_Forms\Gravity_Forms\Form_Display\State

Methods

MethodDescription
flush()Resets the state handler properties to their initial empty values.
get_url()Returns the current page URL without the gf_token query parameter.
create()Creates and returns the value for the state input.
add_additional_values()Hashes and adds any additional non-field values to the state_values property.
add_hashes()Populates the state_values property with the given key and hashes.
is_valid_state_input()Determines if the state input is valid.
is_valid_field()Determines if the submitted values match the state generated on form displayed.
is_valid_additional_value()Determines if the hash of the given value matches the hash parsed from the state input value.
is_valid_url()Determines if the hash of the current page URL matches the hash parsed from the state input value.
get_invalid_counts()Returns the counts for the specified form, setting the invalid_counts property if needed.
cache_invalid_counts()Caches the counts for the specified form.
clear_cached_invalid_counts()Clears the cached counts for the specified form.

Method Reference

flush()

public function flush()

Resets the state handler properties to their initial empty values.

Returns

  • void

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:63

get_url()

public function get_url()

Returns the current page URL without the gf_token query parameter.

Returns

  • string

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:96

create()

public function create( $form, $field_values, $additional_values )

Creates and returns the value for the state input.

Parameters

NameTypeDefaultDescription
$formarrayThe form the state is being generated for.
$field_valuesarrayThe dynamic population values.
$additional_valuesarrayAny additional non-field values to add to the state.

Returns

  • string

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:118

add_additional_values()

public function add_additional_values( $form_id, $values )

Hashes and adds any additional non-field values to the state_values property.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form the state is being generated for.
$valuesarrayThe additional values to add.

Returns

  • void

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:179

add_hashes()

public function add_hashes( $form_id, $key, $hashes )

Populates the state_values property with the given key and hashes.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form the state is being generated for.
$keyint | stringThe key to use when adding the hashes.
$hashesstring | string[]The hash or an array of hashes to add.

Returns

  • void

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:284

is_valid_state_input()

public function is_valid_state_input( $form_id )

Determines if the state input is valid.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form that is being processed.

Returns

  • bool

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:405

is_valid_field()

public function is_valid_field( $field, $values )

Determines if the submitted values match the state generated on form displayed.

Parameters

NameTypeDefaultDescription
$fieldGF_FieldThe field being validated.
$valuesarrayThe input values to be validated.

Returns

  • bool

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:421

is_valid_additional_value()

public function is_valid_additional_value( $form_id, $key, $value )

Determines if the hash of the given value matches the hash parsed from the state input value.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form being validated.
$keystringThe key used to add the hash on form display.
$valuestringThe value to be validated.

Returns

  • bool

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:506

is_valid_url()

public function is_valid_url( $form_id )

Determines if the hash of the current page URL matches the hash parsed from the state input value.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form being validated.

Returns

  • bool

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:527

get_invalid_counts()

public function get_invalid_counts( $form_id )

Returns the counts for the specified form, setting the invalid_counts property if needed.

Parameters

NameTypeDefaultDescription
$form_idintThe form ID.

Returns

  • array

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:565

cache_invalid_counts()

public function cache_invalid_counts( $form_id )

Caches the counts for the specified form.

Parameters

NameTypeDefaultDescription
$form_idintThe form ID.

Returns

  • void

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:614

clear_cached_invalid_counts()

public function clear_cached_invalid_counts( $form_id )

Clears the cached counts for the specified form.

Parameters

NameTypeDefaultDescription
$form_idintThe form ID.

Returns

  • void

Since: 3.0

Source: includes/form-display/state/class-state-handler.php:633