17488 Posts in 4473 Topics by 1978 members
| Go to End | ||
| Author | Topic: | 4470 Views |
-
Re: How can I send a cutom form?

8 July 2008 at 3:46am
Sorry - bu my Contact form isn't working. I receive no mails.
I build in this code:function Form() {
return new Form($this, "Form", new FieldSet(
new TextField("Name", "Name"),
new EmailField("Email", "E-Mail:"),
new FieldSet(
new FormAction("doform", "abschicken")
), new RequiredFields( "", ""
));
}
function doform($data, $form) {
$email = new Email_Template(
'user@user.de',
'me@mysite.com',
'Contact form'
);
$email->ss_template = 'Contact';
$email->populateTemplate(array(
'Name' => $data['Name'],
'Email' => $data['Email'],
));
$email->send();
}I use also a Contact.ss. Are there any errors? How can I give an "OnComplete" message to the user?
-
Re: How can I send a cutom form?

14 July 2008 at 5:42pm
Perhaps this is because server's email configuration has issues. If you create a simple PHP function that just calls "mail('to@example.com', 'subject', 'body');" and visit it, does it send an email?
-
Re: How can I send a cutom form?

14 July 2008 at 10:24pm Last edited: 15 July 2008 1:49am
Hi everyone.
I would like to know if it's possible to change the "The following data was submitted to your website:" message, when the data collected from the form is sent by e-mail.
I've already looked at email templates page and tried to use tiga's code but I can't get it to work.
EDIT: I've changed the message in cms/templates/email/SubmittedFormEmail.ss and it worked.
PS: What does the _t() function do?
-
Re: How can I send a cutom form?

15 July 2008 at 9:24am
the _t function is the SilverStripe translator function - http://doc.silverstripe.com/doku.php?id=i18n
-
Re: How can I send a cutom form?

15 July 2008 at 7:48pm Last edited: 15 July 2008 9:14pm
My contact form is working perfectly. I created this code:
class Page_Controller extends ContentController {
function MyForm() {
$fields = new FieldSet(
new TextField("Name", "Name:"),
new EmailField("Email", "E-Mail:")
);
$validator = new RequiredFields('Name', 'Email',);
$actions = new FieldSet(
new FormAction('doMyForm', 'send')
);
return new Form($this, 'MyForm', $fields, $actions, $validator);
}
function doMyForm($data, $form) {
$email = new Email_Template(
$data['Email'],
'to_me@mysite.com',
'This is your e-mail subject!'
);
$email->ss_template = 'Contact'; // Please create templates/email/Contact.ss
$email->populateTemplate(array(
'Name' => $data['Name'],
'Email' => $data['Email'],
));
$email->send();
Director::redirect("Thanks_for_sending/"); // jumps to site you want to display after sending
}
}You may create this file templates/email/Contact.ss witch will contain all information ($Name, $Email) and send by email to.
I also created a new page in SS called "Thanks_for_sending" and put this content in it. This works perfectly if you don't need other languages. -
Re: How can I send a cutom form?

9 September 2008 at 1:12am
Hi tiga,
tried to use your custom contact form but it doesn't work for me!?
There is one "," too much in the validator listing but that's not the problem...maybe you can post your contac.ss so I can see, what's wrong!? I call the $myFrom and everything (except the validator-language) works fine but I receive no mails!? <mail> function and inbox work!Thanks
Bernhard
| 4470 Views | ||
| Go to Top |





