/**
  * RegistrationForm constructor
  *
  * @param Controller $controller
  * @param String $name
  * @param array $arguments
  */
 public function __construct($controller, $name, $arguments = array())
 {
     /** -----------------------------------------
      * Fields
      * ----------------------------------------*/
     /** @var TextField $firstName */
     $firstName = TextField::create('FirstName');
     $firstName->setAttribute('placeholder', 'Enter your first name')->setAttribute('data-parsley-required-message', 'Please enter your <strong>First Name</strong>')->setCustomValidationMessage('Please enter your <strong>First Name</strong>');
     /** @var EmailField $email */
     $email = EmailField::create('Email');
     $email->setAttribute('placeholder', 'Enter your email address')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>');
     /** @var PasswordField $password */
     $password = PasswordField::create('Password');
     $password->setAttribute('placeholder', 'Enter your password')->setCustomValidationMessage('Please enter your <strong>Password</strong>')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Password</strong>');
     $fields = FieldList::create($email, $password);
     /** -----------------------------------------
      * Actions
      * ----------------------------------------*/
     $actions = FieldList::create(FormAction::create('Register')->setTitle('Register')->addExtraClass('btn--primary'));
     /** -----------------------------------------
      * Validation
      * ----------------------------------------*/
     $required = RequiredFields::create('FirstName', 'Email', 'Password');
     /** @var Form $form */
     $form = Form::create($this, $name, $fields, $actions, $required);
     if ($formData = Session::get('FormInfo.Form_' . $name . '.data')) {
         $form->loadDataFrom($formData);
     }
     parent::__construct($controller, $name, $fields, $actions, $required);
     $this->setAttribute('data-parsley-validate', true);
     $this->addExtraClass('form form--registration');
 }
 /**
  * EmailVerificationLoginForm is the same as MemberLoginForm with the following changes:
  *  - The code has been cleaned up.
  *  - A form action for users who have lost their verification email has been added.
  *
  * We add fields in the constructor so the form is generated when instantiated.
  *
  * @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
  * @param string $name The method on the controller that will return this form object.
  * @param FieldList|FormField $fields All of the fields in the form - a {@link FieldList} of {@link FormField} objects.
  * @param FieldList|FormAction $actions All of the action buttons in the form - a {@link FieldList} of {@link FormAction} objects
  * @param bool $checkCurrentUser If set to TRUE, it will be checked if a the user is currently logged in, and if so, only a logout button will be rendered
  */
 function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     $email_field_label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
     $email_field = TextField::create('Email', $email_field_label, null, null, $this)->setAttribute('autofocus', 'autofocus');
     $password_field = PasswordField::create('Password', _t('Member.PASSWORD', 'Password'));
     $authentication_method_field = HiddenField::create('AuthenticationMethod', null, $this->authenticator_class, $this);
     $remember_me_field = CheckboxField::create('Remember', 'Remember me next time?', true);
     if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
         $fields = FieldList::create($authentication_method_field);
         $actions = FieldList::create(FormAction::create('logout', _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
     } else {
         if (!$fields) {
             $fields = FieldList::create($authentication_method_field, $email_field, $password_field);
             if (Security::config()->remember_username) {
                 $email_field->setValue(Session::get('SessionForms.MemberLoginForm.Email'));
             } else {
                 // Some browsers won't respect this attribute unless it's added to the form
                 $this->setAttribute('autocomplete', 'off');
                 $email_field->setAttribute('autocomplete', 'off');
             }
         }
         if (!$actions) {
             $actions = FieldList::create(FormAction::create('doLogin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField('forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'), new LiteralField('resendEmail', '<p id="ResendEmail"><a href="Security/verify-email">' . _t('MemberEmailVerification.BUTTONLOSTVERIFICATIONEMAIL', "I've lost my verification email") . '</a></p>'));
         }
     }
     if (isset($_REQUEST['BackURL'])) {
         $fields->push(HiddenField::create('BackURL', 'BackURL', $_REQUEST['BackURL']));
     }
     // Reduce attack surface by enforcing POST requests
     $this->setFormMethod('POST', true);
     parent::__construct($controller, $name, $fields, $actions);
     $this->setValidator(RequiredFields::create('Email', 'Password'));
 }
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet("Root", new Tab("Main", HeaderField::create("Application Settings", 3), TextField::create("FacebookConsumerKey", "Consumer Key"), PasswordField::create("FacebookConsumerSecret", "Consumer Secret"), OptionsetField::create("EnableFacebookLogin", "Facebook Login", array(0 => "Disabled", 1 => "Enabled")), OptionsetField::create("EnableFacebookSignup", "Facebook Signup", array(0 => "Disabled", 1 => "Enabled")))));
     $this->extend("updateCMSFields", $fields);
     return $fields;
 }
 public function getPasswordField($confirmed = true)
 {
     if ($confirmed) {
         return ConfirmedPasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'));
     }
     return PasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'));
 }
 public function getPasswordField()
 {
     if ($this->confirmed) {
         //relies on fix: https://github.com/silverstripe/silverstripe-framework/pull/2757
         return ConfirmedPasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'))->setCanBeEmpty(!Checkout::membership_required());
     }
     return PasswordField::create('Password', _t('CheckoutField.PASSWORD', 'Password'));
 }
 /**
  * Creates a form to set a password
  *
  * @return  Form
  */
 public function SetPasswordForm()
 {
     if (!Member::currentUser()) {
         return false;
     }
     $form = Form::create($this->owner, FieldList::create(PasswordField::create('Password', 'Password'), PasswordField::Create('Password_confirm', 'Confirm password'), HiddenField::create('BackURL', '', $this->owner->requestVar('BackURL'))), FieldList::create(FormAction::create('doSetPassword', 'Set my password')), RequiredFields::create('Password', 'Password_confirm'));
     return $form;
 }
 public function __construct($controller, $name, $fields = null, $actions = null)
 {
     $fields = new FieldList($Nickname = TextField::create('Nickname')->setTitle(_t('Member.NICKNAME', 'Member.NICKNAME')), $Type = OptionsetField::create('Type')->setTitle(_t('Member.TYPE', 'Member.TYPE'))->setSource(array("refugee" => _t('Member.TYPEREFUGEESIGNUP', 'Member.TYPEREFUGEESIGNUP'), "hostel" => _t('Member.TYPEHOSTELSIGNUP', 'Member.TYPEHOSTELSIGNUP'), "donator" => _t('Member.TYPEDONATORSIGNUP', 'Member.TYPEDONATORSIGNUP'))), $Location = BootstrapGeoLocationField::create('Location')->setTitle(_t('Member.LOCATION', 'Member.LOCATION')), $Email = EmailField::create('Email')->setTitle(_t('Member.EMAIL', 'Member.EMAIL')), PasswordField::create('Password')->setTitle(_t('Member.PASSWORD', 'Member.PASSWORD')), LiteralField::create('Accept_TOS', _t('SignupForm.CONFIRMTOS', 'SignupForm.CONFIRMTOS')));
     $Type->setRightTitle(_t('Member.TYPEDESCRIPTION', 'Member.TYPEDESCRIPTION'));
     $Location->setRightTitle(_t('Member.LOCATIONDESCRIPTION', 'Member.LOCATIONDESCRIPTION'));
     $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doSignup')->setTitle(_t('SignupForm.BUTTONSIGNUP', 'SignupForm.BUTTONSIGNUP')));
     parent::__construct($controller, $name, $fields, $actions, new RequiredUniqueFields($required = array("Nickname", "Type", "Location", "Email", "Password"), $unique = array("Email" => _t('SignupForm.EMAILEXISTS', 'SignupForm.EMAILEXISTS')), $objectClass = 'Member'));
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($this->ID) {
         $fields->addFieldToTab("Root.Main", TextField::create('InstallID', 'Instalation ID'), "Summary");
         $fields->addFieldToTab("Root.Main", PasswordField::create("ResponsePassword", "Payment Response Password"), "Summary");
     }
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab("Root", new Tab('GoogleAnalytics'));
     $fields->addFieldToTab('Root.GoogleAnalytics', TextField::create("GoogleAnalyticsCode")->setTitle(_t('GoogleConfig.CODE', "Google Analytics Code"))->setRightTitle("(UA-XXXXXX-X)"));
     $fields->addFieldToTab('Root.GoogleAnalytics', TextField::create("GoogleAnalyticsProfileId")->setTitle(_t('GoogleConfig.PROFILEID', "Google Analytics Profile ID"))->setRightTitle(_t('GoogleConfig.PROFILEIDEXPLANATION', 'Hidden in the URL parameter "id" of the "View Report" link inside Google Analytics')));
     $fields->addFieldToTab('Root.GoogleAnalytics', TextField::create("GoogleAnalyticsEmail")->setTitle(_t('GoogleConfig.EMAIL', "Google Analytics Email"))->setRightTitle(_t('GoogleConfig.EMAILEXPLANATION', "The email address of the Google Analytics account to use")));
     $fields->addFieldToTab('Root.GoogleAnalytics', PasswordField::create("GoogleAnalyticsPassword")->setTitle(_t('GoogleConfig.PASSWORD', "Google Analytics Password"))->setRightTitle(_t('GoogleConfig.PASSWORDEXPLANATION', "The password for the above account")));
     $fields->addFieldToTab('Root.GoogleAnalytics', CheckboxField::create('UseGoogleUniversalSnippet')->setTitle(_t('GoogleConfig.UNIVERSAL', 'Use Google Universal Snippet')));
 }
 /**
  * This is a generic form, but it will probably work in most cases.
  *
  * @param array $fields
  * @return array
  */
 public function addInstallFormFields(array $fields)
 {
     $fields[] = HiddenField::create('RepoType', '', $this->getType());
     $fields[] = HiddenField::create('RepoID', '', $this->repoID);
     $fields[] = LiteralField::create('repo', sprintf("<p>" . "You appear to be deploying from %s (%s.git). " . "If you enter your username and password below we will set up a service hook to deploy automatically. " . "Your credentials will not be logged or saved." . "</p>", $this->getHumanName(), $this->repoID));
     $fields[] = TextField::create('PostURL', 'Commit Hook URL (must be unique to this server)', DeployController::default_hook_url());
     $fields[] = TextField::create('ApiUser', $this->getHumanName() . ' Username');
     $fields[] = PasswordField::create('ApiPassword', $this->getHumanName() . ' Password');
     return $fields;
 }
 /**
  * This method holds the functionality to complete the oauth flow through the CMS
  *
  * @param $fields FieldList
  **/
 public function updateCMSFields(FieldList $fields)
 {
     // Remove fields that may have been added elsewhere.
     $fields->removeByName("TwitterUser");
     $fields->removeByName("TwitterScreenName");
     $fields->removeByName("TwitterUserID");
     $fields->removeByName("TwitterAccessToken");
     $fields->removeByName("TwitterAccessSecret");
     // Add our new fields.
     $fields->push(ToggleCompositeField::create('TwitterUser', 'Twitter User', array(TextField::create("TwitterScreenName", "Screen Name"), TextField::create("TwitterUserID", "User ID"), TextField::create("TwitterAccessToken", "Access Token"), PasswordField::create("TwitterAccessSecret", "Access Secret")))->setHeadingLevel(4));
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($this->ID) {
         // Payment Gateway Options
         $email_options = array("Don't", 'Send to customer and vendor', 'Send only to vendor');
         $fields->addFieldToTab("Root.Main", TextField::create('VendorName', 'Vendor name'), "Summary");
         $fields->addFieldToTab("Root.Main", DropdownField::create('ProtocolVersion', 'Version of forms protocol to use?', singleton('SagePay')->dbObject('ProtocolVersion')->enumValues()), "Summary");
         $fields->addFieldToTab('Root.Main', PasswordField::create('EncryptedPassword', 'Password'), "Summary");
         $fields->addFieldToTab("Root.Main", OptionsetField::create('SendEmail', 'How would you like SagePay to send emails?', $email_options), "Summary");
         $fields->addFieldToTab("Root.Main", EmailField::create('EmailRecipient', 'Email address of user to recieve email'), "Summary");
     }
     return $fields;
 }
 public function __construct(Controller $controller, $name)
 {
     // Set default fields
     $fields = new FieldList(HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this), HiddenField::create('tempid', null, $controller->getRequest()->requestVar('tempid')), PasswordField::create("Password", _t('Member.PASSWORD', 'Password')), LiteralField::create('forgotPassword', sprintf('<p id="ForgotPassword"><a href="%s" target="_top">%s</a></p>', $this->getExternalLink('lostpassword'), _t('CMSMemberLoginForm.BUTTONFORGOTPASSWORD', "Forgot password?"))));
     if (Security::config()->autologin_enabled) {
         $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?")));
     }
     // Determine returnurl to redirect to parent page
     $logoutLink = $this->getExternalLink('logout');
     if ($returnURL = $controller->getRequest()->requestVar('BackURL')) {
         $logoutLink = Controller::join_links($logoutLink, '?BackURL=' . urlencode($returnURL));
     }
     // Make actions
     $actions = new FieldList(FormAction::create('dologin', _t('CMSMemberLoginForm.BUTTONLOGIN', "Log back in")), LiteralField::create('doLogout', sprintf('<p id="doLogout"><a href="%s" target="_top">%s</a></p>', $logoutLink, _t('CMSMemberLoginForm.BUTTONLOGOUT', "Log out"))));
     parent::__construct($controller, $name, $fields, $actions);
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     $form_action_url = Controller::join_links(BASE_URL, "Security", $name);
     $lost_password_url = Controller::join_links(BASE_URL, "Security", "lostpassword");
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } else {
         $backURL = Session::get('BackURL');
     }
     $fields = new FieldList(HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this), TextField::create('Identity', 'Username or Email'), PasswordField::create("Password", _t('Member.PASSWORD', 'Password')));
     if (Security::config()->autologin_enabled) {
         $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me?")));
     }
     $actions = new FieldList(FormAction::create('dologin', 'Login'), LiteralField::create('forgotPassword', '<p id="ForgotPassword"><a href="' . $lost_password_url . '">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'));
     // LoginForm does its magic
     parent::__construct($controller, $name, $fields, $actions);
     $this->setAttribute("action", $form_action_url);
 }
 function FoundationForm()
 {
     $fields = new FieldList(HeaderField::create('FormFieldsHeader', 'Form Fields', 3), TextField::create('TextField', 'TextField'), EmailField::create('EmailField', 'EmailField'), PasswordField::create('PasswordField', 'PasswordField'), TextareaField::create('TextareaField', 'TextareaField'), FileField::create('FileField', 'FileField'), CheckboxField::create('CheckboxField', 'CheckboxField'), DropdownField::create('DropdownField', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->setEmptyString(''), CheckboxsetField::create('CheckboxsetField', 'CheckboxsetField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany')), OptionsetField::create('OptionsetField', 'OptionsetField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany')), HeaderField::create('FieldGroupHeader', 'Field Groups', 3), FieldGroup::create(TextField::create('FieldGroupTextField', 'TextField')->addExtraClass('small-6 columns'), TextField::create('FieldGroupTextField1', 'TextField')->addExtraClass('small-6 columns')), FieldGroup::create(TextField::create('FieldGroupTextField2', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField3', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField4', 'TextField')->addExtraClass('small-4 columns')), FieldGroup::create(TextField::create('FieldGroupTextField5', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField6', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField7', 'TextField')->addExtraClass('small-3 columns'), TextField::create('FieldGroupTextField8', 'TextField')->addExtraClass('small-3 columns')), FieldGroup::create(TextField::create('FieldGroupTextField9', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField10', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField11', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField12', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField13', 'TextField')->addExtraClass('large-2 small-4 columns'), TextField::create('FieldGroupTextField14', 'TextField')->addExtraClass('large-2 small-4 columns')), FieldGroup::create(TextField::create('FieldGroupTextField15', 'TextField')->addExtraClass('small-6 columns'), TextField::create('FieldGroupTextField16', 'TextField')->addExtraClass('small-4 columns'), TextField::create('FieldGroupTextField17', 'TextField')->addExtraClass('small-2 columns')), FieldGroup::create(DropdownField::create('DropdownField2', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->addExtraClass('large-6 small-6 columns')->setEmptyString(''), DropdownField::create('DropdownField3', 'DropdownField')->setSource(array('NZ' => 'New Zealand', 'US' => 'United States', 'GEM' => 'Germany'))->addExtraClass('large-6 small-6 columns')->setEmptyString('')), HeaderField::create('SwitchFieldsHeader', 'Switch Fields', 3), FoundationSwitchField::create('SwitchField', 'SwitchField', array(0 => 'Off', 1 => 'On'))->addExtraClass('large-12'), FoundationSwitchField::create('SwitchField2', 'SwitchField', array(0 => 'Off', 1 => 'On'))->addExtraClass('large round'));
     $actions = new FieldList(new FormAction('submitFoundationForm', 'Submit'));
     // set all to required to see the validation message appearance
     $required = array();
     if ($dataFields = $fields->dataFields()) {
         foreach ($dataFields as $child) {
             $required[] = $child->getName();
         }
     }
     $validator = new RequiredFields($required);
     $form = new FoundationForm($this, __FUNCTION__, $fields, $actions, $validator);
     // load submitted data, and clear them from session
     if ($data = Session::get('FoundationForm' . $this->ID)) {
         $form->loadDataFrom($data);
         Session::clear('FoundationForm' . $this->ID);
     }
     return $form;
 }
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(HeaderField::create("Application Settings", 3));
     $fields->push(TextField::create("TwitterConsumerKey", "Consumer Key"));
     $fields->push(PasswordField::create("TwitterConsumerSecret", "Consumer Secret"));
     $fields->push(OptionsetField::create("EnableTwitterLogin", "Twitter Login", array(0 => "Disabled", 1 => "Enabled")));
     $this->extend("updateCMSFields", $fields);
     return $fields;
 }
 /**
  * Set if the existing password should be required
  *
  * @param bool $show Flag to show or hide this field
  * @return $this
  */
 public function setRequireExistingPassword($show)
 {
     // Don't modify if already added / removed
     if ((bool) $show === $this->requireExistingPassword) {
         return $this;
     }
     $this->requireExistingPassword = $show;
     $name = $this->getName();
     $currentName = "{$name}[_CurrentPassword]";
     if ($show) {
         $confirmField = PasswordField::create($currentName, _t('Member.CURRENT_PASSWORD', 'Current Password'));
         $this->children->unshift($confirmField);
     } else {
         $this->children->removeByName($currentName, true);
     }
     return $this;
 }
示例#18
0
 /**
  * Creates the registration form
  *
  * @return  BootstrapForm
  */
 public function RegistrationForm()
 {
     $url = Controller::curr()->getRequest()->requestVar('BackURL');
     $speaker_registration_token = Controller::curr()->getRequest()->requestVar(SpeakerRegistrationRequest::ConfirmationTokenParamName);
     $fields = FieldList::create($first_name = TextField::create('FirstName', 'Your First Name'), $last_name = TextField::create('Surname', 'Your Last Name'), $email = EmailField::create('Email', 'Your email address'), PasswordField::create('Password', 'Password'), PasswordField::create('Password_confirm', 'Confirm your password'), HiddenField::create('BackURL', '', $url));
     if (!empty($speaker_registration_token)) {
         $request = $this->speaker_registration_request_repository->getByConfirmationToken($speaker_registration_token);
         if (is_null($request) || $request->alreadyConfirmed()) {
             return $this->httpError(404, 'speaker registration request not found!');
         }
         // auto-populate fields
         $fields->add(HiddenField::create(SpeakerRegistrationRequest::ConfirmationTokenParamName, '', $speaker_registration_token));
         $first_name->setValue($request->proposedSpeakerFirstName());
         $last_name->setValue($request->proposedSpeakerLastName());
         $email->setValue($request->proposedSpeakerEmail());
     }
     $form = BootstrapForm::create($this, 'RegistrationForm', $fields, FieldList::create(FormAction::create('doRegister', 'Register now')), RequiredFields::create('FirstName', 'Surname', 'Email', 'Password', 'Password_confirm'));
     $data = Session::get("FormInfo.{$form->getName()}.data");
     return $form->loadDataFrom($data ?: array());
 }