Is there a way to auto populate the Title field with current date? Basically Im wondering if the Title field can be auto- filled in with the current date when creating a new entry. EE 6
-
As a general rule you will get a more informative answer to your question if you follow a couple of simple principles: give some details of the version of EE that you are working with (and possibly what hosting environment); and give some contextual information about the issue you are having - for example in this case is this when entering / editing a channel entry in the Control Panel or some other circumstance?– JCOGS DesignJan 24, 2021 at 13:39
1 Answer
Install the free MX CP CSS & JS add-on and add the following code to the JS field in the settings of the add-on:
$(document).ready(function(){
var currentDate = Date.now();
var today = new Date(currentDate);
var dateString = today.toLocaleDateString();
var titleField = $('input[name="title"]');
var url = $(location).attr('href');
if(titleField.length && url.indexOf('/cp/publish/create/') > 0) {
titleField.val(dateString + " ");
}
});
It will populate the title field with the current date with a trailing space.