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:17

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.

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:53

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:85

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:107

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:168

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:273

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:384

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:400

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:481

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:502