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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

problem with populateTemplate


Go to End


1812 Views

Avatar
bebabeba

Community Member, 193 Posts

4 February 2009 at 12:31am

Edited: 04/02/2009 5:51am

Hi!
I read some post how to send mail. My problem is about populateTemplate:

Object::__call() Method 'populateTemplate' not found in class ''
At line 199 in E:\_silverstripe_cms\silverstripe\sapphire\core\Object.php

This is what I wrote:

function SendMail() {

// Create fields
$fields1 = new FieldSet(
new TextField(
$name = "nome",
$title = "Nome*:",
$value = ""
)
);
$actions = new FieldSet(
new FormAction('doSendMail', 'Invia')
);
return new Form($this, 'SendMail', $fields1, $actions);
}

function doSendMail($data, $form)
{
$from="elisa";
$to="xxxx@xxxxxxxx.it";
$subject="ciao";
$body="ciao ciao";

$e = new Email($from, $to, $subject, $body, "","","");
$e->populateTemplate(array('Nome'=>$data['nome']));
$e->send();

Director::redirectBack();
}