To auto populate page title in a title field based on path value selected in path browser field, you can refer following code snippet-
$(document).ready(function() {
var textInput;
var textToInput;
var inputText;
var ui = $(window).adaptTo("foundation-ui");
var s = $(document).on("dialog-ready", function() {
textInput = $('.js-coral-pathbrowser-button').parent().prev();
textToInput = $('.js-coral-pathbrowser-button').parent().parent().parent().parent().parent().parent().parent().find("input[name='./page'].coral-Form-field");
$(document).on("click", ".js-coral-pathbrowser-confirm", function() {
setTimeout(function() {
inputText = $(textInput).val();
//$(textToInput).val(inputText.substring(inputText.lastIndexOf("/")+1).split('.')[0]);
if (!$(textToInput).val()) {
$(textToInput).val(inputText.substring(inputText.lastIndexOf("/") + 1));
}
}, 1000);
})
$(document).on('click', '.js-coral-pathbrowser-button', function() {
textInput = $(this).parent().prev();
textToInput = $(this).parent().parent().parent().parent().parent().parent().parent().find("input[name='./page'].coral-Form-field");
})
$(document).on("change", " .js-coral-pathbrowser-input", function() {
inputText = $(this).val();
if (inputText.indexOf("/content") > 0) {
textToInput = $(this).parent().parent().parent().parent().parent().parent().parent().find("input[name='./page'].coral-Form-field");
if (!$(textToInput).val()) {
$(textToInput).val(inputText.substring(inputText.lastIndexOf("/") + 1));
}
}
});
});
});
Change the field selector input[name='./page'].coral-Form-field as per your dialog configuration where the title value is to be auto populated.
You need to put the above code in a clientlibs JS file with category "cq.authoring.dialog".