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.

Gform_field_standard_settings more advanced examples

  1. Jive Software
    Member

    I am having difficulty with Gform_field_standard_settings.
    The example in documentation is very a simplistic example and I wish they provided several different examples...

    http://www.gravityhelp.com/documentation/page/Gform_field_standard_settings

    I am trying to repurpose this to use a simple input text box but having a difficult time figuring how to prepopulate the box after the user has entered the data. I am also having a difficult time figuring out how to access the entry object and form object from this filter... I tried declaring globals and or passing more then 2 arguments into the function.

    Steve

    Posted 12 years ago on Wednesday September 5, 2012 | Permalink
  2. Can you show us the code you are using and the form you are working with? We should be able to help you better with more information.

    Posted 12 years ago on Thursday September 6, 2012 | Permalink
  3. Jive Software
    Member

    add_action("gform_field_standard_settings", "my_marketo_settings", 10, 2);
    
    function my_marketo_settings($position, $form_id){
    
    	if($position == 0) {
    	?>
    		<li class="marketo_setting field_setting">
    				<label for="field_marketo_label">
    						<?php _e("Marketo Field Name", "gravityforms"); ?>
    						<?php
    							gform_tooltip("form_field_marketo_name")
    						?>
    				</label>
            <input type="text"  id="field_marketo_name" class="fieldwidth-3" onfocus="SetFieldProperty('marketoName', this.value);" value="" size="35"/>
    		</li>
    	<?php
    	}
    }
    
    add_action("gform_editor_js", "editor_script");
    
    function editor_script(){
        ?>
        <script type='text/javascript'>
    
    				jQuery.each(fieldSettings, function(index, value) {
    					fieldSettings[index] += ", .marketo_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_marketo_name").attr("value", field["marketoName"]);
            });
        </script>
        <?php
    }
    
    add_filter('gform_tooltips', 'add_my_marketo_tooltips');
    
    function add_my_marketo_tooltips($tooltips){
       $tooltips["form_field_marketo_name"] = "<h6>Marketo Name</h6>Enter the marketo field name";
       return $tooltips;
    }
    Posted 12 years ago on Thursday September 6, 2012 | Permalink
  4. Jive Software
    Member

    Now the issue I am having is if prexisting data was saved in the field_marketo_name and I change it something new and click the update form button. The information does not save.

    Posted 12 years ago on Thursday September 6, 2012 | Permalink
  5. Jive Software
    Member

    I was able to find a solution....

    It seems the value is appended via javascript and it uses the same input html for each field... So I need to detect the to see if the custom property exisited, and if "undefined" then set value attribute to blank...

    add_action("gform_editor_js", "editor_script");
    function editor_script(){
        ?>
        <script type='text/javascript'>
    				jQuery.each(fieldSettings, function(index, value) {
    					fieldSettings[index] += ", .marketo_setting";
    				});
    
    				jQuery(document).bind("gform_load_field_settings", function(event, field, form) {
    
    					if (typeof field["marketoName"] !== "undefined") {
    						jQuery("#field_marketo_name").attr("value", field["marketoName"]);
    					} else {
    						jQuery("#field_marketo_name").attr("value", '');
    					}
    
    				});
    
        </script>
        <?php
    }
    Posted 12 years ago on Thursday September 6, 2012 | Permalink
  6. I'm glad you got that worked out. Thank you for posting your update.

    Posted 12 years ago on Friday September 7, 2012 | Permalink