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.

Creating a New Field

  1. So I have "successfully" created a new field; however, none of the properties or the advanced input areas appear (as I would like to use some of the default ones). How do I 'enable' them?

    Here's my attempt so far:

    Posted 10 years ago on Wednesday December 14, 2011 | Permalink
  2. Hello Travis,
    If you look at the following doc page, there is a sample on how to create a new custom setting.
    In that example, note line 24:

    fieldSettings["text"] += ", .encrypt_setting";

    This line is assigning the new custom setting "encrypt_setting" to fields of type text. You will need to do something similar to your custom field, but replacing "text" with your custom field name. You can also assign any of the built-in settings such as label, default value, conditional logic, etc... I don't have a full list of all available settings, but if you look at the end of the gravityforms/js/forms.js file, you will see how the built-in settings are assigned to the existing fields. That should help you choose the settings you need for your field.

    Posted 10 years ago on Wednesday December 14, 2011 | Permalink
  3. Thanks Alex. I've incorporated this; however, this adds a placement input area to OTHER fields, but not the newly created custom field, TOS.

    Here's the newly added code from the previous pastebin:

    add_action( "gform_editor_js", "my_gform_editor_js" );
    function my_gform_editor_js(){
    <script type='text/javascript'>
    	//adding setting to fields of type "text"
    	fieldSettings["textarea"] += ", .tos_setting";
    	//binding to the load field settings event to initialize the checkbox
    	jQuery(document).bind("gform_load_field_settings", function(event, field, form){

    New pastebin:

    Is there a way to add a conditional. What I am trying to do is to create an advanced version of the Paragraph Text. And this is a big stumbling block for me. In essence I want to add an input text box to the Settings, but everything else should be the same.

    Pic of my new custom field:
    Pic of the paragraph field:

    Posted 10 years ago on Thursday December 15, 2011 | Permalink
  4. You are close. In your code snippet above, replace:

    fieldSettings["textarea"] += ", .tos_setting";


    //Add all textarea settings to the "TOS" field plus custom "tos_setting"
    fieldSettings["tos"] = fieldSettings["textarea"] + ", .tos_setting";
    Posted 10 years ago on Thursday December 15, 2011 | Permalink
  5. Now, when I test the Field Size, it is not resizing appropriately. Isn't this accurate?

    // Adds the input area to the external side
    add_action( "gform_field_input" , "wps_tos_field_input", 10, 5 );
    function wps_tos_field_input ( $input, $field, $value, $lead_id, $form_id ){
        if ( $field["type"] == "tos" ) {
    		$max_chars = "";
    		if(!IS_ADMIN && !empty($field["maxLength"]) && is_numeric($field["maxLength"]))
    			$max_chars = self::get_counter_script($form_id, $field_id, $field["maxLength"]);
    		$input_name = $form_id .'_' . $field["id"];
    		$tabindex = GFCommon::get_tabindex();
    		return sprintf("<div class='ginput_container'><textarea name='input_%s' id='%s' class='textarea %s' $tabindex rows='10' cols='50'>%s</textarea></div>{$max_chars}", $field["id"], 'tos-'.$field['id'] , $field["type"] . ' ' . esc_attr($field['cssClass']) , esc_html($value));
        return $input;
    Posted 10 years ago on Thursday December 15, 2011 | Permalink
  6. Hello,

    I figured out the issue. You can close this topic.



    Posted 10 years ago on Monday December 19, 2011 | Permalink
  7. Thanks Travis. Care to post your revised code?

    Posted 10 years ago on Tuesday December 20, 2011 | Permalink

This topic has been resolved and has been closed to new replies.