public function testInsertBeforeMissing()
 {
     $form = $this->form->enableSpamProtection(array('protector' => 'FormSpamProtectionExtensionTest_FooProtector', 'insertBefore' => 'NotAField'));
     // field should default to the end instead
     $fields = $form->Fields();
     $this->assertEquals('Title', $fields[0]->Title());
     $this->assertEquals('Comment', $fields[1]->Title());
     $this->assertEquals('URL', $fields[2]->Title());
     $this->assertEquals('Foo', $fields[3]->Title());
 }
 public function alterCommentForm(Form $form)
 {
     $form->transform(new FoundationFormTransformation());
     $form->setTemplate('FoundationCommentingControllerForm', 'FoundationForm', 'Form');
     $form->addExtraClass('custom');
     if ($form->hasExtension('FormSpamProtectionExtension')) {
         $form->enableSpamProtection();
     }
 }
 public function alterCommentForm(Form $form)
 {
     $form->Fields()->bootstrapify();
     $form->Actions()->bootstrapify();
     $form->setTemplate('FoundationCommentingControllerForm', 'FoundationForm');
     if ($form->hasExtension('FormSpamProtectionExtension')) {
         $form->enableSpamProtection();
     }
     Requirements::css(FOUNDATIONFORMS_DIR . '/css/foundationforms.css');
 }
 public function Form()
 {
     $fields = new FieldList(new TextField('Name'), new EmailField('Email'), new TextareaField('Content'));
     $actions = new FieldList(new FormAction('doSubmit', 'Submit'));
     $validator = new RequiredFields('Name', 'Content');
     $form = new Form($this, 'Form', $fields, $actions, $validator);
     $form->enableSpamProtection(array('protector' => 'AkismetSpamProtector', 'name' => 'IsSpam', 'mapping' => array('Content' => 'body', 'Name' => 'authorName', 'Email' => 'authorMail')));
     // Because we don't want to be testing this
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * @uses   MemberProfilePage_Controller::getProfileFields
  * @return Form
  */
 public function RegisterForm()
 {
     $form = new Form($this, 'RegisterForm', $this->getProfileFields('Registration'), new FieldList(new FormAction('register', _t('MemberProfiles.REGISTER', 'Register'))), new MemberProfileValidator($this->Fields()));
     if ($form->hasExtension('FormSpamProtectionExtension')) {
         $form->enableSpamProtection();
     }
     $this->extend('updateRegisterForm', $form);
     return $form;
 }
 /**
  * @uses   MemberProfilePage_Controller::getProfileFields
  * @return Form
  */
 public function ProfileForm()
 {
     $fields = $this->getProfileFields('Profile');
     $fields = $this->RegistrationFields($fields);
     // need to fill with stored values. sort out saving first
     $form = new Form($this, 'ProfileForm', $fields, new FieldList(new FormAction('save', _t('MemberProfiles.SAVE', 'Save'))), new MemberProfileValidator($this->Fields(), Member::currentUser()));
     $form->enableSpamProtection();
     $this->extend('updateProfileForm', $form);
     return $form;
 }
Example #7
0
 /**
  * @uses   MemberProfilePage_Controller::getProfileFields
  * @return Form
  */
 public function ProfileForm()
 {
     $fields = $this->getProfileFields('Profile');
     $fields = $this->RegistrationFields($fields);
     $member = Member::currentUser();
     $actionTitle = 'Save';
     if ($member->MembershipStatus === 'Expired') {
         $actionTitle = 'Renew';
     }
     if ($member->MembershipStatus === 'Not applied') {
         $actionTitle = 'Join';
     }
     $form = new Form($this, 'ProfileForm', $fields, new FieldList(new FormAction('save', $actionTitle)), new MemberProfileValidator($this->Fields(), Member::currentUser()));
     $form->enableSpamProtection();
     $this->extend('updateProfileForm', $form);
     return $form;
 }
 /**
  * @return Form
  */
 public function Form()
 {
     $fields = $this->GameFields();
     $form = new Form($this, 'Form', $fields, new FieldList(new FormAction('addgamesubmission', 'Submit')));
     $form->enableSpamProtection();
     return $form;
 }
 public function EmailProtectionForm()
 {
     $fields = new FieldList();
     $actions = new FieldList(FormAction::create('dounlockemails'));
     $form = new Form($this, 'EmailProtectionForm', $fields, $actions);
     $form->enableSpamProtection();
     return $form;
 }
 /**
  * @return Form
  */
 public function Form()
 {
     // Attempt to retrieve a current registration for the logged in member
     $reg = $this->getCurrentRegistration();
     $register = RegistrationPage::get()->First();
     // If the user has no registration, redirect them to the registration page
     if (!$reg) {
         if ($register) {
             return $this->redirect($register->AbsoluteLink());
         } else {
             return $this->redirect($this->baseURL);
         }
     }
     if (!$this->userGameRegOpen()) {
         return false;
     }
     // If the user has already added games, redirect them to after submission
     // @todo: allow users to edit submitted game choices
     if ($reg->PlayerGames()->Count() > 0) {
         return $this->redirect($this->Link('yourgames'));
     }
     $fields = $this->GameSignupFields($reg);
     $form = new Form($this, 'Form', $fields, new FieldList(new FormAction('addplayergames', 'Submit')));
     $form->enableSpamProtection();
     $form->addExtraClass('preference-select');
     return $form;
 }
 /**
  * Factory method for the registration form
  *
  * @return Form Returns the registration form
  */
 function RegistrationForm()
 {
     $data = Session::get("FormInfo.Form_RegistrationForm.data");
     $use_openid = $this->getForumHolder()->OpenIDAvailable() == true && (isset($data['IdentityURL']) && !empty($data['IdentityURL'])) || isset($_POST['IdentityURL']) && !empty($_POST['IdentityURL']);
     $fields = singleton('Member')->getForumFields($use_openid, true);
     // If a BackURL is provided, make it hidden so the post-registration
     // can direct to it.
     if (isset($_REQUEST['BackURL'])) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $_REQUEST['BackURL']));
     }
     $validator = singleton('Member')->getForumValidator(!$use_openid);
     $form = new Form($this, 'RegistrationForm', $fields, new FieldList(new FormAction("doregister", _t('ForumMemberProfile.REGISTER', 'Register'))), $validator);
     // Guard against automated spam registrations by optionally adding a field
     // that is supposed to stay blank (and is hidden from most humans).
     // The label and field name are intentionally common ("username"),
     // as most spam bots won't resist filling it out. The actual username field
     // on the forum is called "Nickname".
     if (ForumHolder::$use_honeypot_on_register) {
         $form->Fields()->push(new LiteralField('HoneyPot', '<div style="position: absolute; left: -9999px;">' . '<label for="RegistrationForm_username">' . _t('ForumMemberProfile.LeaveBlank', 'Don\'t enter anything here') . '</label>' . '<input type="text" name="username" id="RegistrationForm_username" value="" />' . '</div>'));
     }
     $member = new Member();
     // we should also load the data stored in the session. if failed
     if (is_array($data)) {
         $form->loadDataFrom($data);
     }
     // Optional spam protection
     if (class_exists('SpamProtectorManager') && ForumHolder::$use_spamprotection_on_register) {
         $form->enableSpamProtection();
     }
     return $form;
 }