0

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

1
  • 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? Jan 24, 2021 at 13:39

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.