bookmark_borderGF_Field_Product

Introduction

The GF_Field_Product class extends the GF_Field class, also known as the Field Object. This class is responsible for handling the Product field. Because Product fields are either a Single Product, Drop Down, Radio Button, User Defined Price, Hidden or Calculation, this class only adds some settings and sets the title for the field in the editor. The rendering of the Product field is handled by the class associated with its sub-type. The field “type” property will be set to product. Depending on the product field chosen, the field “inputType” property will be *singleproduct**, “select”, “radio”, “price”, “hiddenproduct”, or “calculation”.

For more details about rendering the Option field, check out the articles below:

Calculation – GF_Field_calculation class
Drop Down – GF_Field_select class
Hidden Product – GF_Field_hiddenproduct class
Radio Buttons – GF_Field_radio class
Single Product – GF_Field_singleproduct class
User Defined Price – GF_Field_price class

Settings and Properties

Settings control what options are available to the admin user when configuring the field in the form editor. Gravity Forms includes many built-in settings such as Field Label, Field Description, Choices, Conditional Logic, etc. In addition to built-in settings, custom settings can also be developed. For more information on how to develop custom settings and how to associate settings to a field, visit the GF_Field page.

Properties contain the values specified by the settings and generally are part of the Field Object.

The properties may be retrieved by accessing the Field Object as follows:

//get the field
$field = GFFormsModel::get_field( $form, 1 );

//get the admin label
$admin_label = $field->adminLabel;

Settings

The following settings are available for the field:

  • admin_label_setting
    Controls whether the “Admin Field Label” setting appears.

  • css_class_setting
    Controls whether the “Custom CSS Class” setting displays. This allows a custom css to be used for the field.

  • default_value_setting
    Controls whether the “Default Values” section displays. This allows a value to be set for the field.

  • description_setting
    Controls whether the “Description” setting appears. This allows a description for the field to be displayed.

  • label_setting
    Controls whether the “Field Label” setting which allows the label to be changed appears.

  • prepopulate_field_setting
    Controls whether the “Allow field to be populated dynamically” setting appears.

  • product_field_type_setting
    Determines whether the “Field Type” section displays. This allows the product field to be set to a specific type: Single Product, Drop Down, Radio Buttons, User Defined Price, Hidden, or Calculation.

##Source Code
The source code is located in includes/fields/class-gf-field-product.php in the Gravity Forms folder of your sites plugins directory.