$subject = '[' . $page->form_prefix . '] ';
}
+ if (isset($validatedData['subject'])) {
+ $subject .= $validatedData['subject'];
+ }
+
$sender = '';
if (isset($validatedData['firstname'])) {
$sender .= $validatedData['firstname'];
}
$message->replyTo($validatedData['email'], $sender);
- $message->subject($subject . $validatedData['subject']);
+ $message->subject($subject);
});
}
type: $(this).attr('method'),
data: $(this).serialize(),
}).done(function (response) {
- $(form).find('.error').removeClass('error');
- // Todo: make this more customisable from the form
- $(form).html('<p class="center text-2xl text-center p-8" >' + $(form).data('confirmation') + '</p>');
+ let responseClasses = form.data('confirmation-classes') || 'text-2xl text-center p-8';
+ form.find('.error').removeClass('error');
+ form.html(`<p class="${responseClasses}">${form.data('confirmation')}</p>`);
}).fail(function (response) {
button.text(button.data('text')).prop('disabled', false);
- $(form).find('.error').removeClass('error');
- $(form).find('.errormessage').remove();
+ form.find('.error').removeClass('error');
+ form.find('.errormessage').remove();
$.each(response.responseJSON.errors, function (k, v) {
if (v.length > 0) {
- var field = $(form).find('[name="' + k + '"]');
+ var field = form.find('[name="' + k + '"]');
$(field).addClass('error');
$('<span class="errormessage">' + v[0] + '</span>').insertBefore(field);
}
{{ __('Inscription Newsletter') }}
</h3>
-<form action="/ajax/newsletter" method="post" class="ajax-form mailform text-navy" data-confirmation="{{ __('Merci, vous avez été inscrit avec succès') }}" novalidate>
+<form action="/ajax/newsletter" method="post" class="ajax-form mailform text-navy"
+ data-confirmation="{{ __('Merci, vous avez été inscrit avec succès') }}"
+ data-confirmation-classes="text-green-500"
+ novalidate>
<label for="newsletter_email" class="form-input">{{ __('Email') }}
<input type="email" name="email" id="newsletter_email" class="py-3 mt-3" required>
</label>