Jump to content

pioneer5555

Member
  • Posts

    1
  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    pioneer5555 reacted to Beyondspace in Form Submission, Unique Subject   
    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

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.