Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » use PopulateTemplate to email form content, need help???

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

Page: 1
Go to End
Author Topic: 2284 Views
  • Vesalius
    Avatar
    Community Member
    2 Posts

    use PopulateTemplate to email form content, need help??? Link to this post

    I've made a custom form which I want to mail and am using PopulateTemplate to format this mail however I get the following error testing in a wamp environment.:

    FATAL ERROR: Object::__call() Method 'populateTemplate' not found in class ''
    At line 199 in C:\wamp\www\silverstripe\sapphire\core\Object.php

    user_error(Object::__call() Method 'populateTemplate' not found in class '',256)
    line 199 of Object.php

    Object->__call(populateTemplate,Array)
    Email->populateTemplate(Array)
    line 168 of ReceptenPage.php

    ReceptenPage_Controller->doReceptAanvraagForm(Array,Form)
    line 238 of Controller.php

    Controller->run(Array)
    line 22 of ModelAsController.php

    ModelAsController->run(Array)
    line 104 of Director.php

    Director::direct(/uitproberen/)
    line 158 of main.php

    Context

    This is my code and I can't find where I went wrong, I've made a ReceptTemplate.ss in mysite/templates/email:

       function doReceptAanvraagForm($data, $form) {

          $email = new Email(
             $from = $data['email'],
             $to = "mymailadres@gmail.com",
             $subject = "Receptaanvraag"
          );
          $email->ss_template = "ReceptTemplate";
          $templateData = array(
          "Anaam" => $data["Anaam"],
             "Vnaam" => $data["Vnaam"]
          );
          $email->populateTemplate($templateData);
          $email->send();

          // Redirect to a page thanking people for registering
          Director::redirect('uitproberen/');
       }

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: use PopulateTemplate to email form content, need help??? Link to this post

    Which version of Silverstripe are you using?

    I think pre 2.3 you had to use new Email_Template instead of new Email. The Email_Template was a subclass of Email.

    In 2.3 this has been changed and I think it was all merged into one class Email, so if you're still using an older version, populateTemplate will not be a method of Email.

    The docs are already for 2.3, so this is pretty confusing.

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: use PopulateTemplate to email form content, need help??? Link to this post

    Hi!
    I have the same problem and I change Email with Email_Template but in this way mail don't go to sender..With Email was ok. I have v2.2.2

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: use PopulateTemplate to email form content, need help??? Link to this post

    I noticed this as well....

    It looks like you need to use email_template in 2.2.2 and Email in 2.3 ....

    2284 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.