PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Adding dropdown field to hidden fields in form administration

  1. I've successfully added a dropdown option in form administration directly under the field label using gform_field_standard_settings. This dropdown is showing for ALL fields EXCEPT for the hidden field. Is there a separate hook I need to use to add the dropdown to the hidden field type as well?

    Here's the code I'm using to add the dropdown. Any help would be greatly appreciated.

    // ADD ADF FIELD IDENTIFIER TO ALL FIELDS
    
    add_action("gform_field_standard_settings", "my_standard_settings", 10, 2);
    
    function my_standard_settings($position, $form_id){
    
    // Create settings on position 25 (right after Field Label)
    
    if($position == 25){
    ?>
    
    <li class="admin_label_setting field_setting" style="display: list-item; ">
    <label for="adf_field">ADF Field Type
    
    <!-- Tooltip to help users understand what this field does -->
    <a href="javascript:void(0);" class="tooltip tooltip_form_field_placeholder" tooltip="<h6>ADF Field Type</h6>To pass a form value as an ADF form field, please select an option from the list below.">(?)</a>
    
    </label>
    
    <select id="adf_field" name="adf_field" onchange="SetFieldProperty('adf_field', this.value);">
      <option value="0">PLEASE SELECT</option>
      <option value="CustomerName">CUSTOMER : Name</option>
      <option value="CustomerEmail">CUSTOMER : Email</option>
      <option value="CustomerPhone">CUSTOMER : Phone</option>
      <option value="CustomerComments">CUSTOMER : Comments</option>
      <option value="VehicleYear">VEHICLE : Year</option>
      <option value="VehicleMake">VEHICLE : Make</option>
      <option value="VehicleModel">VEHICLE : Model</option>
      <option value="VehicleComments">VEHICLE : Comments</option>
      <option value="VendorName">VENDOR : Name</option>
      <option value="VendorContact">VENDOR : Contact</option>
      <option value="VendorPhone">VENDOR : Phone</option>
      <option value="VendorEmail">VENDOR : Email</option>
      <option value="ProviderName">PROVIDER : Name</option>
      <option value="ProviderService">PROVIDER : Service</option>
      <option value="ProviderURL">PROVIDER : URL</option>
      <option value="ProviderEmail">PROVIDER : Email</option>
      <option value="ProviderPhone">PROVIDER : Phone</option>
    </select>
    
    </li>
    <?php
    }
    }
    
    // SAVE AND LOAD FIELD SETTING ON ADMIN SIDE
    
    add_action("gform_editor_js", "my_gform_editor_js");
    
    function my_gform_editor_js(){
    ?>
    <script>
    //binding to the load field settings event
    jQuery(document).bind("gform_load_field_settings", function(event, field, form){
    jQuery("#adf_field").val(field["adf_field"]);
    });
    </script>
    
    <?php
    }
    Posted 12 years ago on Friday September 7, 2012 | Permalink
  2. In dire need here guys. I realize it's the weekend, but is anyone around? Should I just create a custom field type that acts the same way as a hidden field, and apply it that way instead? There must be a better way...

    Posted 12 years ago on Sunday September 9, 2012 | Permalink
  3. You are almost there, but you have missed a step. You need to give a unique class to your setting and then configure which field types will be able to see it. You are using admin_label_setting, and that setting is not supported by the hidden field, so that is why it is not displayed for that field. You will want to do the following:
    1- Change admin_label_setting with a unique class for your new field property (i.e. my_custom_setting).
    2- Assign your class above to each field type that you would like this setting to apply to.
    More specifically, if you would like this setting to be visible by hidden fields and text fields, add the following lines to your my_gform_editor_js()

    fieldSettings["hidden"] += ", .my_custom_setting";
    fieldSettings["text"] += ", .my_custom_setting";

    I hope this helps.

    Posted 12 years ago on Monday September 10, 2012 | Permalink
  4. Thank you. Exactly what I needed to know. Where is this in the documentation?

    Posted 12 years ago on Saturday September 22, 2012 | Permalink