I followed @Ian_A approach with the new localized form block update in mind, the below script can work with multiple forms on the page and use the localized date format string as the unique value for the subject. The subject form field will be hidden after the form has been loaded
nit: remember to set the label and placeholder of field to Subject
cc: @stefansegers and @creedon for further discussion
Put this into website's Footer injection
<script>
/*
* @beyondspace: Unique submission subject
* Squarespace Forum: 14-June-2023
*/
window.addEventListener("load", (event) => {
const formBlocks = document.querySelectorAll('.sqs-block-form');
const triggerInputChange = (inputElement, value) => {
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
window.HTMLInputElement.prototype,
"value"
).set;
nativeInputValueSetter.call(inputElement, value);
const inputEvent = new Event("input", { bubbles: true });
inputElement.dispatchEvent(inputEvent);
}
formBlocks.forEach((block) => {
const timestamp = new Date().toLocaleString(Static.SQUARESPACE_CONTEXT.website.language);
const subjectInput = block.querySelector(`[placeholder="Subject"]`);
if (subjectInput) {
const subjectField = subjectInput.closest(`.form-item`);
subjectField.hidden = true;
triggerInputChange(subjectInput, timestamp)
}
})
});
</script>
The emails will be sent as