Jump to:

10854 Posts in 2518 Topics by 1794 members

All other Modules

SilverStripe Forums » All other Modules » Captcha field results in white page

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1072 Views
  • Mediaversa
    Avatar
    Community Member
    5 Posts

    Captcha field results in white page Link to this post

    Hello everyone,

    I'm trying to add a ReCaptcha field to my contact page's field. However when a form is filled including the captcha, the page directs me to a blank page, and the form is not send. The code i've used for the form:

    ------------------

    <?php
    class ContactPage extends Page
    {
       static $db = array(
       'Mailto' => 'Varchar(100)',
       'SubmitText' => 'HTMLText'
       );
       
       function getCMSFields() {
       $fields = parent::getCMSFields();
       
       $fields->addFieldToTab("Root.Content.OnSubmission", new TextField('Mailto', 'Email submissions to'));
       $fields->addFieldToTab("Root.Content.OnSubmission", new TextareaField('SubmitText', 'Text on Submission'));
       
       return $fields;
       }
    }

    class ContactPage_Controller extends Page_Controller
    {
       function ContactForm()
       {
          $Params = Director::urlParams();
          // Create fields
          $fields = new FieldSet(
          new TextField('Bezoekdatum', 'Bezoekdatum *'),
          new TextField('Naam', 'Naam *'),
          new TextField('Vereniging', 'Vereniging'),
          new TextField('Adres', 'Adres / Nr *'),
          new TextField('Postcode', 'Postcode / Plaats *'),
          new TextField('Telefoon', 'Telefoon / Mobiel *'),
          new EmailField('ContactEmail', 'Email *'),
          new TextField('Aantal', 'Aantal Personen: (volwassenen en kinderen onder de 12) *'),
          new TextField('Tijdstip', 'Tijdstip *'),
          new DropdownField('Rondleiding', 'Rondleiding door de molens *',array("Ja"=> "Ja" , "Nee" => "Nee", ),''),
          new DropdownField('Wandeling', 'Wandeling met natuurgids *',array("Ja"=> "Ja" , "Nee" => "Nee"),''),
          new TextField('Drinken', 'Koffie / Thee (aantal invullen) *'),
          new TextField('Koek', 'Molenkoek (aantal invullen) *'),
          new TextareaField('Wensen','Overige wensen/vragen',4,16)
    );
          
          // Create action
          $actions = new FieldSet(
          new FormAction('SendContactForm', 'Verzenden')
          );
          
          // Create Validators
          $validator = new RequiredFields('Naam', 'ContactEmail', 'Bezoekdatum', 'Adres', 'Postcode', 'Telefoon', 'Aantal', 'Tijdstip', 'Rondleiding', 'Wandeling', 'Drinken', 'Koek');
          
          //return new Form($this, 'ContactForm', $fields, $actions, $validator);
          $form = new Form($this, 'ContactForm', $fields, $actions, $validator);
          $protector = SpamProtectorManager::update_form($form, 'Comments'); // to make the recaptcha work with your form
          return $form;
       }
       
       function SendContactForm($data)
       {
          
          //Set data
          $From = $data['ContactEmail'];
          $To = $this->Mailto;
          $Subject = "Aanmelding voor rondleiding via de website";
          $email = new Email($From, $To, $Subject);
          //set template
          $email->setTemplate('TourEmail');
          //populate template
          $email->populateTemplate($data);
          //send mail
          $email->send();
          //return to submitted message
          Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");
       }
       
       public function Success()
       {
          return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
       }
    }

    ------------------

    Hope somebody knows a solution for this,

    thx,
    Xander

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Captcha field results in white page Link to this post

    the page directs me to a blank page

    Have you got display_errors turned on in your php.ini file (or can you look at your PHP error log for any errors).

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