fix(builder): emit ContactForm successMessage as a data attribute (D1b)
successMessage was collected in props (and FormStylePanel already had a live "Success Message" input for it) but toHtml never emitted it anywhere. The form-sender relay delivers success via a full-page 303 redirect to thankYouUrl or a hosted thanks.php page -- there is no in-page JS today that could reveal an inline success element. Emit it as data-whp-success-message (escaped) on the <form>: forward-compatible for a future AJAX submission mode, without implying a live mechanism that doesn't exist yet. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -211,8 +211,15 @@ ContactForm.craft = {
|
||||
|
||||
const { marker, actionAttr, honeypot } = relayFormWiring(props.recipientEmail, props.thankYouUrl, props.formAction);
|
||||
|
||||
// The form-sender relay delivers success via a full-page 303 redirect
|
||||
// (to thankYouUrl or a hosted thanks.php page) -- there is no in-page JS
|
||||
// that reveals an inline success element today. Emit successMessage as a
|
||||
// forward-compatible data attribute so a future AJAX/JS submission mode
|
||||
// can read it, without implying a live mechanism that doesn't exist yet.
|
||||
const successAttr = props.successMessage ? ` data-whp-success-message="${escapeAttr(props.successMessage)}"` : '';
|
||||
|
||||
return {
|
||||
html: `${marker}<form action="${actionAttr}" method="POST"${formStyle ? ` style="${formStyle}"` : ''}>
|
||||
html: `${marker}<form action="${actionAttr}" method="POST"${successAttr}${formStyle ? ` style="${formStyle}"` : ''}>
|
||||
${honeypot ? ` ${honeypot}\n` : ''}${fieldsHtml ? ` ${fieldsHtml}\n` : ''} <button type="submit"${btnStyle ? ` style="${btnStyle}"` : ''}>${escapeHtml(props.submitText || 'Send Message')}</button>
|
||||
</form>`,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user