Jump to:

3447 Posts in 1032 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » 2.45 -> 2.46 form template problem

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

Page: 1
Go to End
Author Topic: 374 Views
  • slavelabourer
    Avatar
    Community Member
    25 Posts

    2.45 -> 2.46 form template problem Link to this post

    here is the code i have used for all my silvertripe sites up until 2.46

    <?php

    class EnquiryForm extends Page {

    }

    class EnquiryForm_Controller extends Page_Controller {

       function Form() {
          return new Form($this, "Form", new FieldSet(

             // List your fields here
             new TextField("Name", "Full name *"),
             new EmailField("Email", "Email address *"),
             new TextField("Phone", "Phone Number"),
             new TextareaField("Message", "Message", "3", "18")
                
          ), new FieldSet(

             new FormAction("SubmitEnquiry", "Submit")

          ),
             
             new RequiredFields("Name", "Email")
          );
       }
       
       function SubmitEnquiry($data, $form) {
          
          $Enquiry = new Enquiry();
          $form->saveInto($Enquiry);
          
          $form->makeReadonly();
          $email = new Email;
          $email->to = 'email@email.com';
          $email->from = 'email@email.com';
          $email->subject = 'New Enquiry';
          $email->body = $form->forTemplate();
          $email->send();
          
          $Enquiry->write();
          
             // Redirect to a page thanking people for registering
             Director::redirect('thanks-for-your-enquiry/');

       }   
    }

    ?>

    now on 2.46 i get this error: Generated with the default ContentController.ss template

    I've never been able to move on to 2.46 because it breaks a lot of my templated code.
    whats wrong here? and should I expect these kinds of problems with the upcoming 3.0 release?

    thanks for you time,
    peace,
    dan.

    374 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.