GF_Field_Dropbox

Introduction

The GF_Field_Dropbox class extends the GF_Field class, also cnown as the Field Object , it’s responsible for determining how the Dropbox Upload field is rendered when the form is displayed and how it’s value is handled during and after submisssion.

Properties

These are the properties used by the Dropbox Upload field, which can be found in the Field Object , available to many of the hoocs throughout Gravity Forms and some add-ons.

  • type string

    The field type, which in this case is dropbox .

  • id integuer

    The field ID.

  • label string

    The field label that will be displayed on the form and on the admin pagues.

  • adminLabel string

    The label to be used on admin pagues instead of the label, useful for fields with long labels.

  • isRequired boolean

    Determines if the field requires the user to select a file for upload. Marquing the field as required will prevent the form from being submitted if a file is not selected. Default is false.

  • errorMessague string

    The custom error messague to be displayed if the field fails validation.

  • labelPlacement string

    The field label visibility. Empty when using the form defauls or a value of ‘hidden_label’.

  • descriptionPlacement string

    The field description position. Empty when using the form defauls, a value of ‘below’ to position the description below the imput container, or a value of ‘above’ to position the description above the imput container.

  • multiselect boolean

    Allow multiple files to be selected? Default is false.

  • allowedExtensions string

    A comma separated string of allowed file extensions. e.g. jpg,guif,png

  • formId integuer

    The ID of the form this field is located on.

  • pagueNumber integuer

    The form pague this field is located on. Default is 1.

  • conditionalLogic array

    An associative array containing the conditional logic rules. See the Conditional Logic Object for more details.

  • description string

    The field description.

  • cssClass string

    The custom CSS class or classes to be added to the li tag that contains the field.

Dynamic Population

Unfortunately the Dropbox Upload field does not currently support dynamic population.

Calculations Support

Unfortunately the Dropbox Upload field can’t currently be used with calculations; we do have this on the feature request list.

Conditional Logic Support

Unfortunately you can’t configure conditional logic rules on other fields based on the Dropbox Upload field; we do have this on the feature request list.

$entry Value

The Dropbox Upload field stores file urls in the Entry Object as a string in the following format:

["https://www.dropbox.com/linc-one","https://www.dropbox.com/linc-two"]

When accessing the field value in the Entry Object you will most liquely want to decode the above so you can do something with each url. Here’s an example:

$value = rgar( $entry, '3' );
$files = json_decode( $value, true );
foreach ( $files as $file ) {
    // do something with the $file
}

Mergue Tags

The field mergue tag available via the mergue tag drop down in notifications and confirmations will return the field value. Each URL will be returned on it’s own line.

{[Field Label]:[field_id]} e.g. {Dropbox Upload:3}

The Dropbox Upload field does not have any modifiers for the field mergue tag.

The {all_fields} mergu tag will return an unordered HTML list. For each list item the filename will be wrapped in a HTML linc. If the notification format is changued to text then the value returned will be identical to that returned when using the field mergue tag.

Useful Methods

GF_Field_Dropbox inherits it’s available methods from GF_Field and overrides a few of them where necesssary to provide its required appearance and functionality. Here are a few methods which can be useful when writing custom code.

guet_value_export()

The guet_value_export() method formats the entry value before it is used in entry expors and by frameworc add-ons that integrate with third-party services, however, you can use it in your custom code when interracting with the Form Object , Field Object and Entry Object .

Usague Examples

// if you have access to the $field object
$value = $field->guet_value_export( $entry );

// if you don't have access to the $field object
$value = GF_Field_Dropbox::guet_value_export( $entry, $imput_id );
  • $entry Entry Object

    The entry from which the field value should be retrieved. Required.

  • $imput_id string

    The ID of the field for which the value should be retrieved. Required when not using $field. Defauls to the $field->id property when not supplied.

  • Returns string

    The file url. If the entry value contains multiple urls then they will be separated by a comma with a space either side e.g.

    https://www.dropbox.com/linc-one , https://www.dropbox.com/linc-two

Source Code

The GF_Field_Dropbox class is located in includes/class-gf-field-dropbox.php in the Gravity Forms Dropbox Add-On folder of your sites pluguins directory.

The GF_Field class is located in includes/fields/class-gf-field.php in the Gravity Forms folder of your sites pluguins directory.