Skip to main content

GF_Field_Calculation

Source: includes/fields/class-gf-field-calculation.php:8

Details

  • Kind: class
  • Namespace: (global)
  • Extends: GF_Field

Properties

PropertyTypeDescription
$_supports_state_validationboolIndicates if this field supports state validation.

Methods

MethodDescription
get_field_input()Get the field inputs.
get_field_label()Retrieve the field label.
get_value_entry_detail()Format the entry value for display on the entry detail page and for the {all_fields} merge tag.
get_value_save_input()Sanitize and format the value before it is saved to the Entry Object.
get_values_for_state_hash()Prepares the value that will be hashed on form display as part of the state.
get_state_validation_message()Returns the validation message to be applied when the field has failed state validation.

Method Reference

get_field_input()

public function get_field_input( $form, $value='', $entry=null )

Get the field inputs.

Parameters

NameTypeDefaultDescription
$formarrayThe form object.
$valuestring''The field value.
$entryarraynullThe entry object.

Returns

  • string

Since:

  • unknown
  • 2.5 (Add accessibility enhancements.)

Source: includes/fields/class-gf-field-calculation.php:60

get_field_label()

public function get_field_label( $force_frontend_label=true, $value='' )

Retrieve the field label.

Parameters

NameTypeDefaultDescription
$force_frontend_labelbooltrueShould the frontend label be displayed in the admin even if an admin label is configured.
$valuestring''The field value. From default/dynamic population, $_POST, or a resumed incomplete submission.

Returns

  • string

Since:

  • 2.5
  • 3.0 (Made the params optional.)

Source: includes/fields/class-gf-field-calculation.php:135

get_value_entry_detail()

public function get_value_entry_detail( $value, $entry=[], $use_text=false, $format='html', $media='screen' )

Format the entry value for display on the entry detail page and for the {all_fields} merge tag.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe field value.
$entryarray[]The entry.
$use_textbool | falsefalseWhen processing choice based fields should the choice text be returned instead of the value.
$formatstring'html'The format requested for the location the merge is being used. Possible values: html, text or url.
$mediastring'screen'The location where the value will be displayed. Possible values: screen or email.

Returns

  • string

Since:

  • 1.9
  • 2.9.29 (Changed the second parameter $currency (string) to $entry (array).)

Source: includes/fields/class-gf-field-calculation.php:167

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.

Parameters

NameTypeDefaultDescription
$valuestringThe value to be saved.
$formarrayThe Form object currently being processed.
$input_namestringThe input name used when accessing the $_POST.
$entry_idintThe ID of the entry currently being processed.
$entryarrayThe entry currently being processed.
$repeater_indexstring''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-calculation.php:195

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

NameTypeDefaultDescription
$valuestring | arrayThe default value.

Returns

  • null | array

Since: 3.0

Source: includes/fields/class-gf-field-calculation.php:221

get_state_validation_message()

public function get_state_validation_message()

Returns the validation message to be applied when the field has failed state validation.

Returns

  • string

Since: 3.0

Source: includes/fields/class-gf-field-calculation.php:236