Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Gravityforms - Exclude custom field using FieldSettings WordPress

Using the example from the GravityForms documentation at http://www.gravityhelp.com/documentation/page/Gform_field_standard_settings I have this...

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="encrypt_setting field_setting">
<label for="field_admin_label">
<?php _e("Encryption", "gravityforms"); ?>
</label>
<input type="checkbox" id="field_encrypt_value" onclick="SetFieldProperty('encryptField', this.checked);" /> encrypt field value
</li>
<?php
}
}

add_action("gform_editor_js", "editor_script");
function editor_script(){
?>
<script type='text/javascript'>
//adding setting to fields of type "text"
fieldSettings["text"] += ", .encrypt_setting";

//binding to the load field settings event to initialize the checkbox
jQuery(document).bind("gform_load_field_settings", function(event, field, form){
jQuery("#field_encrypt_value").attr("checked", field["encryptField"] == true);
});
</script>
<?php
}

This works great and adds the encrypt option to all of the fields with a type of 'text'.

I have created some custom fields that have the following values...

fieldSettings["myfield"]
fieldSettings["customnumber"]
fieldSettings["customanswer"]

These are all text fields but I do not want the encrypt checkbox above to be applied to them. How can I exclude these fields from being affected by fieldSettings["text"] += ", .encrypt_setting";

Answers (1)

2014-02-19

Dbranes answers:

Hi

You can try this to only show the <em>Encrypt</em> options for field with id 11:


//binding to the load field settings event to initialize the checkbox
jQuery(document).bind("gform_load_field_settings", function(event, field, form){

jQuery( '#field_settings li.encrypt_setting' ).hide();

// Visible for field with id 11
if( '11' == field['id'] )
{
jQuery( '#field_settings li.encrypt_setting' ).show();
jQuery("#field_encrypt_value").attr("checked", field["encryptField"] == true);
}
});


Here's a screenshot of how it's only visible for field with id 11 but not for a field with id 14:

[[LINK href="http://i.imgur.com/Oz7ctwD.gif"]]http://i.imgur.com/Oz7ctwD.gif[[/LINK]]


Did you try to implement it?