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.

Add datepicker or datepicker classes to a list field

  1. I have a list field that I would like to include dates in. I was hoping there is a way though using some of the available filters to add the necessary classes to get a datepicker to show up, but I can't figure out how to target my specific field using gform_field_css_class and recreating the input using gform_field_input for a list type seems daunting. Is there a good way to go about this?

    Posted 12 years ago on Tuesday May 29, 2012 | Permalink
  2. Same question here?

    add_filter('gform_column_input_6_3_4','gform6_set_column_date_picker');
    function gform6_set_column_date_picker(){
    	return array("type" => "date");
    }
    Posted 11 years ago on Thursday March 21, 2013 | Permalink
  3. Hi Collectiv,

    It's been a while back since I did this, but what I ended up doing was adding a script like this:

    jQuery(document).ready(function($) {
    	$('.gfield_list_51_cell1 input').addClass('datepicker mdy');
    
    	$.aop.after( {target: window, method: 'gformAddListItem'}, function(result) {
    				//Destroy the previous datepicker classes that were mucking this up
    				$('.datepicker').removeClass('hasDatepicker');
    				$('.datepicker').datepicker('destroy');
    
    				//Call the datepicker function to re-add date pickers
    				gformInitDatepicker();
    
                   return result;
             } );
    });

    That bit of code relies on aop.min.js, which you can find here: https://code.google.com/p/jquery-aop/source/browse/bin/aop.min.js?r=d1052368b0769afe20f6b09bdc371acf6f2246a6

    And I edited the gravityforms.js file at line 563 -- this is an old version now, but it is inside the gformAddListItem function:

    var new_id;
    	var randomNum;
    	clone.find(".datepicker").each(
    	 function() {
    	 	randomNum = Math.floor(Math.random()*11);
    	   	new_id = new Date().getTime() + randomNum;
    	   	jQuery(this).attr("id", new_id);
    		}
    	);

    If this doesn't work for you it might be out of date, but let me know and I'll try to help! I know it took me some time to get it working so hopefully this will help you out. You'll have to be careful when updating your GF version to put the edits back in.

    Posted 11 years ago on Friday March 22, 2013 | Permalink
  4. This functionality is not included in Gravity Forms at this time and we can't support modifications to the core files. Please be sure to keep track of your edits so they are maintained after updating Gravity Forms.

    Posted 11 years ago on Sunday March 24, 2013 | Permalink

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