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
| Method | Description |
|---|---|
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
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The form the state is being generated for. | |
$field_values | array | The dynamic population values. | |
$additional_values | array | Any 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The ID of the form the state is being generated for. | |
$values | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The ID of the form the state is being generated for. | |
$key | int | string | The key to use when adding the hashes. | |
$hashes | string | 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field | The field being validated. | |
$values | array | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The ID of the form being validated. | |
$key | string | The key used to add the hash on form display. | |
$value | string | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | The ID of the form being validated. |
Returns
bool
Since: 3.0
Source: includes/form-display/state/class-state-handler.php:502