Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Email a Copy of Form Submission

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 737 Views
  • zenmonkey
    Community Member
    528 Posts

    Email a Copy of Form Submission Link to this post

    I'm trying to set up a Form that gets emailed to an admin once its submitted but it doesn't seem to be working. Here is the Form and Submit function from my RegistrationPage_Controller

    function UserRegistrationForm() {
    // Create fields
        $companyTypeList = array(
             'Retail' => 'Retail',
             'Online' => 'Online',
             'Distributor' => 'Distributor',
             'Press' => 'Press'
        $recaptchaField = new RecaptchaField('');
        $recaptchaField->jsOptions = array('theme' => 'white');
    $fields = new FieldSet(
                          new FieldGroup (
                                      new HeaderField('Personal Information', 3),
                                      new LiteralField("explanation","<p>To Set-up Your Account</p>"),
                                      new TextField('FirstName', 'First Name'),
                                      new TextField('Surname','Last Name'),
                                      new EmailField('Email','Email'),
                                      new ConfirmedPasswordField('Password'),
                          new FieldGroup (
                                      new HeaderField('Company Information', 3),
                                      new LiteralField("explanation","<p>To Verfiy Eligibility</p>"),
                                      new TextField('CompanyName','Company Name'),
                                      new TextField('CompanyURL','Company Website'),
                                      new TextField('HomePhone','Company Phone'),
                                      new TextField('Address','Address'),
                                      new TextField('AddressLine2','Address Line 2'),
                                      new TextField('City','City'),
                                      new TextField('State','State or Province'),
                                      new TextField('Country','Country'),
                                      new TextField('TaxIDNumber','TaxIDNumber'),
                                      new TextField('Distributor','Distributor'),
                                      new TextField('SalesRep','Sales Rep'),
                                      new DropdownField('CompanyType','Company Type',$companyTypeList),
                                      new TextareaField('Notes','Description'),
                                      new HiddenField('PageID', '', $this->ID)
    // Create actions
    $actions = new FieldSet(
    new FormAction('doApplication', 'Submit')
    return new Form($this, 'UserRegistrationForm', $fields, $actions);

    function doApplication($data, $form) {
    $application = new UserApplication();
        $application->RegistrationPageID = $this->ID;
        //return print_r($application);

        //E-mail Review Contents:
        //Set data
        $From = $data['Email'];
        $To = "hardcoded@email.address";
        $Subject = "New User Registration" . + $data['Email'];
        $email = new Email($From, $To, $Subject);
        //send mail

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.