GF_Field_Radio
Source: includes/fields/class-gf-field-radio.php:9
Details
- Kind:
class - Namespace:
(global) - Extends: GF_Field
Properties
| Property | Type | Description |
|---|---|---|
$_supports_state_validation | bool | Indicates if this field supports state validation. |
Methods
| Method | Description |
|---|---|
get_form_editor_field_description() | Returns the field's form editor description. |
get_form_editor_field_icon() | Returns the field's form editor icon. |
is_state_valid() | Determines the if the field has been tampered with before submission. |
skip_state_validation_if_blank() | Indicates if state validation should be skipped if the submitted value is blank. |
get_values_for_state_hash() | Prepares the value that will be hashed on form display as part of the state. |
get_value_for_state_validation() | Returns the value to use when the state is validated. |
get_field_container_tag() | Returns the HTML tag for the field container. |
add_aria_description() | Determine if we should add the aria description to a radio input. |
get_choice_html() | Returns the choice HTML. |
get_legacy_choice_html() | Returns the choice HTML. |
get_value_merge_tag() | Gets merge tag values. |
get_value_save_input() | Sanitize and format the value before it is saved to the Entry Object. For radio fields with 'other' option enabled, extracts the user-entered text from the array. |
get_other_choice_value_from_post() | Extracts the "other" choice value from POST data, handling nested repeater arrays. |
sanitize_entry_value() | Strip scripts and some HTML tags. |
get_filter_operators() | Returns the filter operators for the current field. |
get_entry_inputs() | Override to return null instead of the array of inputs in case this is a choice field. |
Method Reference
get_form_editor_field_description()
public function get_form_editor_field_description()
Returns the field's form editor description.
Returns
string
Since: 2.5
Source: includes/fields/class-gf-field-radio.php:33
get_form_editor_field_icon()
public function get_form_editor_field_icon()
Returns the field's form editor icon.
This could be an icon url or a gform-icon class.
Returns
string
Since: 2.5
Source: includes/fields/class-gf-field-radio.php:46
is_state_valid()
public function is_state_valid( $value )
Determines the if the field has been tampered with before submission.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The submitted value. |
Returns
bool
Since: 3.0
Source: includes/fields/class-gf-field-radio.php:82
skip_state_validation_if_blank()
public function skip_state_validation_if_blank( $key )
Indicates if state validation should be skipped if the submitted value is blank.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$key |
Returns
bool
Since: 3.0
Source: includes/fields/class-gf-field-radio.php:97
get_values_for_state_hash()
public function get_values_for_state_hash( $value )
Prepares the value that will be hashed on form display as part of the state.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The default value. |
Returns
null|array
Since: 3.0
Source: includes/fields/class-gf-field-radio.php:110
get_value_for_state_validation()
public function get_value_for_state_validation( $value )
Returns the value to use when the state is validated.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | array | The submitted value. |
Returns
array
Since: 3.0
Source: includes/fields/class-gf-field-radio.php:137
get_field_container_tag()
public function get_field_container_tag( $form )
Returns the HTML tag for the field container.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | The current Form object. |
Returns
string
Since: 2.5
Source: includes/fields/class-gf-field-radio.php:159
add_aria_description()
public function add_aria_description( $checked, $choice_id )
Determine if we should add the aria description to a radio input.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$checked | string | The checked attribute or a blank string. | |
$choice_id | int | The choice number. |
Returns
string
Since: 2.5
Source: includes/fields/class-gf-field-radio.php:279
get_choice_html()
public function get_choice_html( $choice, &$choice_id, $value, $disabled_text, $is_admin )
Returns the choice HTML.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$choice | array | The choice properties. | |
&$choice_id | int | The choice number. | |
$value | string | The current field value. | |
$disabled_text | string | The disabled attribute or an empty string. | |
$is_admin | bool | Indicates if this is the form editor or entry detail page. |
Returns
string
Since:
Source: includes/fields/class-gf-field-radio.php:308
get_legacy_choice_html()
public function get_legacy_choice_html( $choice, &$choice_id, $value, $disabled_text, $is_admin )
Returns the choice HTML.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$choice | array | The choice properties. | |
&$choice_id | int | The choice number. | |
$value | string | The current field value. | |
$disabled_text | string | The disabled attribute or an empty string. | |
$is_admin | bool | Indicates if this is the form editor or entry detail page. |
Returns
string
Since: 2.5
Source: includes/fields/class-gf-field-radio.php:398
get_value_merge_tag()
public function get_value_merge_tag( $value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br )
Gets merge tag values.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | array | string | The value of the input. | |
$input_id | string | The input ID to use. | |
$entry | array | The Entry Object. | |
$form | array | The Form Object | |
$modifier | string | The modifier passed. | |
$raw_value | array | string | The raw value of the input. | |
$url_encode | bool | If the result should be URL encoded. | |
$esc_html | bool | If the HTML should be escaped. | |
$format | string | The format that the value should be. | |
$nl2br | bool | If the nl2br function should be used. |
Returns
string— The processed merge tag.
Since: Unknown
Source: includes/fields/class-gf-field-radio.php:521
get_value_save_input()
public function get_value_save_input( $value, $form, $input_name, $entry_id, $entry, $repeater_index='' )
Sanitize and format the value before it is saved to the Entry Object. For radio fields with 'other' option enabled, extracts the user-entered text from the array.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | The value to be saved. | |
$form | array | The Form object currently being processed. | |
$input_name | string | The input name used when accessing the $_POST. | |
$entry_id | int | The ID of the entry currently being processed. | |
$entry | array | The entry currently being processed. | |
$repeater_index | string | '' | The repeater index if the field is inside a repeater. |
Returns
array|string— The sanitized and formatted input value to be saved.
Since: 3.0.0
Source: includes/fields/class-gf-field-radio.php:587
get_other_choice_value_from_post()
public function get_other_choice_value_from_post( $item_index=null )
Extracts the "other" choice value from POST data, handling nested repeater arrays.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$item_index | string | null | null | Optional explicit index (for get_value_save_input). |
Returns
string— The extracted other value, or empty string if not found.
Since: 3.0.0
Source: includes/fields/class-gf-field-radio.php:630
sanitize_entry_value()
public function sanitize_entry_value( $value, $form_id )
Strip scripts and some HTML tags.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | The field value to be processed. | |
$form_id | int | The ID of the form currently being processed. |
Returns
string
Source: includes/fields/class-gf-field-radio.php:669
get_filter_operators()
public function get_filter_operators()
Returns the filter operators for the current field.
Returns
array
Since: 2.4
Source: includes/fields/class-gf-field-radio.php:698
get_entry_inputs()
public function get_entry_inputs()
Override to return null instead of the array of inputs in case this is a choice field.
Returns
array|null
Since: 2.9
Source: includes/fields/class-gf-field-radio.php:711