Hi everyone, I am trying to add a date field onto our gravity form that automatically enters the current date.
I am not a developer and only use the form settings available. Is this possible?
Sure, you can use this method:
add_filter( 'gform_field_value_current_date', 'populate_current_date' );
function populate_current_date( $value ) {
$local_timestamp = GFCommon::get_local_timestamp( time() );
return date_i18n( 'm/d/Y', $local_timestamp, true );
}
Where do I add that code?
At the moment I am adding fields from the menu on the right (there is w=one called date) and I can’t work out where to add that code in the date field/advanced tab?
That is PHP code that has added to your theme functions.php file. Be sure to read that page from the top to be sure you set up your field correctly.
If your Date Input Type is Date Picker, you can add the merge tag {date_mdy}
or {date_dmy}
for Default Value of the field under the Advanced tab. Of course, the user will be able to change this unless you make the field Read Only or Hidden.
4 Likes