Skip to main content
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
I'm looking for solution how to add custom email template on user defined form ( contact form ) submits .
When form is emailed it looks like it using Page.ss which is bad for me:)
How to add customized template for emailed submitted user form?
There's 2 solutions:
1. You make a contact form in code, rather than use the 'contact form' in the CMS - this way you get full control over making it. See the 3rd tutorial for more information on this.
2. Subclass UserDefinedForm, and hack the code so it chooses a different template. (Not the best solution).
can u help to place dropdown controls from middle of the page ... help me please
OK, I used
http://doc.silverstripe.com/doku.php?id=email_template end works almost perfect but there are three problems:
1. How to add translated validation messages? Page is in Polish and have to translate validation messages
2. How to add proper encoding to email? I have bad characters when email is submitted
3. How to add confirmation message that the email has been send
function doContactForm ( $data, $form )
$submission = new ContactFormSubmission();
// send email
$email = new Email_Template();
$email->ss_template = "ContactFormEmail";
$email->subject = $submission->val( "Subject" );
$email->from = $submission->val("Email");
$email->to = "firstname.lastname@example.org";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<p>WiadomoÃ…â€ºÃ„â€¡ wysÃ…â€šana przez $Name z formularza kontaktowego:</p>
Ok now I need only two answers:)
3. How to add confirmation message that the email has been send?
I had to add SubmittedContactArticlePage.ss and works perfect:)
Just before Director::redirectBack() you can call:
$form->sessionMessage('Thanks, you've been signed up', 'good');
Are there some messages like 'good' for replacing validation messages?