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.

Dynamically Populate New List Items

  1. bleepa
    Member

    Hi,

    I have a form where a user can enter events into a 4 column list, where I am pre-populating the second column with tomorrow's date.

    //Prepopulate list with tomorrow's date
    function populate_date($value){
    	$current_date = date( "d/m/Y", strtotime( "tomorrow" ) );
    	return array( "",$current_date,"","" );
    }
    add_filter("gform_field_value_list", "populate_date");

    This works for the first row, which makes sense considering I am returning a one row array. However, I was wondering if there was an easy way to pre-populate any extra rows that are added by the user, without having to return an array with an arbitrary number of rows.

    Posted 11 years ago on Sunday August 12, 2012 | Permalink
  2. David Peralty

    Not that I know of because we wouldn't know how many rows they would need and those rows don't exist until they add them.

    Posted 11 years ago on Monday August 13, 2012 | Permalink
  3. Gravity Forms currently doesn't have a built-in way of doing this. What you can try doing is hook into the plus button click using jQuery and populate the date field using javascript. But you will need somebody with javascript/jQuery experience to be able to do that.

    Posted 11 years ago on Monday August 13, 2012 | Permalink