/**
  * Returns an instance of this class
  *
  * @param Controller $controller
  * @param string $name
  */
 public function __construct($controller, $name)
 {
     $fields = new FieldList(array(new HiddenField('AuthenticationMethod', null, $this->authenticator_class)));
     $actions = new FieldList(array(FormAction::create('redirectToRealMe', _t('RealMeLoginForm.LOGINBUTTON', 'LoginAction'))->setUseButtonTag(true)->setButtonContent('<span class="realme_button_padding">Login or register with RealMe<span class="realme_icon_new_window"></span> <span class="realme_icon_padlock"></span>')->setAttribute('class', 'realme_button')));
     // Taken from MemberLoginForm
     if (isset($_REQUEST['BackURL'])) {
         $backURL = $_REQUEST['BackURL'];
     } elseif (Session::get('BackURL')) {
         $backURL = Session::get('BackURL');
     }
     if (isset($backURL)) {
         // Ensure that $backURL isn't redirecting us back to login form or a RealMe authentication page
         if (strpos($backURL, 'Security/login') === false && strpos($backURL, 'Security/realme') === false) {
             $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
         }
     }
     // optionally include requirements {@see /realme/_config/config.yml}
     if ($this->config()->include_jquery) {
         Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
     }
     if ($this->config()->include_javascript) {
         Requirements::javascript(REALME_MODULE_PATH . "/javascript/realme.js");
     }
     if ($this->config()->include_css) {
         Requirements::css(REALME_MODULE_PATH . "/css/realme.css");
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
 public function testGetField()
 {
     $formAction = new FormAction('test');
     $this->assertContains('type="submit"', $formAction->getAttributesHTML());
     $formAction->setAttribute('src', 'file.png');
     $this->assertContains('type="image"', $formAction->getAttributesHTML());
 }
    public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
    {
        if (!$fields) {
            $helpHtml = _t('GroupImportForm.Help1', '<p>Import one or more groups in <em>CSV</em> format (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
            $helpHtml .= _t('GroupImportForm.Help2', '<div class="advanced">
	<h4>Advanced usage</h4>
	<ul>
	<li>Allowed columns: <em>%s</em></li>
	<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the 
	imported file</li>
	<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>
	<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not
	cleared.</li>
	</ul>
</div>');
            $importer = new GroupCsvBulkLoader();
            $importSpec = $importer->getImportSpec();
            $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
            $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
            $fileField->getValidator()->setAllowedExtensions(array('csv'));
        }
        if (!$actions) {
            $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
            $action->addExtraClass('ss-ui-button');
            $actions = new FieldList($action);
        }
        if (!$validator) {
            $validator = new RequiredFields('CsvFile');
        }
        parent::__construct($controller, $name, $fields, $actions, $validator);
        $this->addExtraClass('cms');
        $this->addExtraClass('import-form');
    }
Example #4
0
 function TrialSignupForm()
 {
     $cardType = array("visa" => "<img src='themes/attwiz/images/visa.png' height=30px></img>", "mc" => "<img src='themes/attwiz/images/mastercard.jpeg' height=30px></img>", "amex" => "<img src='themes/attwiz/images/ae.jpeg' height=30px></img>", "discover" => "<img src='themes/attwiz/images/discover.jpeg' height=30px></img>");
     $monthArray = array();
     for ($i = 1; $i <= 12; $i++) {
         $monthArray[$i] = date('F', mktime(0, 0, 0, $i));
     }
     $yearArray = array();
     $currentYear = date('Y');
     for ($i = 0; $i <= 10; $i++) {
         $yearArray[$currentYear + $i] = $currentYear + $i;
     }
     $trialExpiryDate = date('F-j-Y', mktime(0, 0, 0, date('n') + 1, date('j'), date('Y')));
     $subscriptionInfo = "<div id='SubscriptionInfo'><h2>Post-Trial Subscription Selection</h2>\n\t    <p>Your 10 heatmaps will expire on {$trialExpiryDate}, at which time your account \n\t    will be replenished with a new allocation of heatmap credits according to the \n\t    subscription level you choose below. You may cancel your subscription any time \n\t    before your trial period ends and your  credit card will only be charged 1 dollar.</p></div>";
     $subscriptionType = array("1" => "Bronze - (10 heatmaps for \$27.00 / month)", "2" => "Silver - (50 heatmaps for \$97.00 / month)", "3" => "Gold - (200 heatmaps for \$197.00 / month)");
     $whatsThis = '<span id="WhatsThis"><a id="WhatsThisImage" href="themes/attwiz/images/cvv.jpg" title="What\'s this?">What\'s this?</a></span>';
     $fields = new FieldList(new TextField('FirstName', 'First Name'), new TextField('LastName', 'Last Name'), new TextField('Company', 'Company(optional)'), new TextField('StreetAddress1', 'Street Address1'), new TextField('StreetAddress2', 'Street Address2(optional)'), new TextField('City', 'City'), new TextField('State', 'State/Province'), new TextField('PostalCode', 'Zip/Poatal Code'), new CountryDropdownField('Country'), new OptionsetField('CreditCardType', 'Credit Card Type', $cardType, 'visa'), new TextField('NameOnCard', 'Name On Card'), new NumericField('CreditCardNumber', 'Credit Card Number'), new PasswordField('CVVCode', 'Security/CVV Code'), new LiteralField('WhatIsThis', $whatsThis), new DropdownField('ExpirationMonth', 'Expiration Date', $monthArray), new DropdownField('ExpirationYear', '', $yearArray), new LiteralField('SubscriptionInfo', $subscriptionInfo), new OptionsetField('SubscriptionType', '', $subscriptionType, '1'), new CheckboxField('Agreement', ' I understand that this is a recurring subscription and I will be billed monthly unless I cancel.'));
     // Create action
     $actions = new FieldList($submit = new FormAction('doSignup', 'Start Trial'));
     $submit->setAttribute('src', 'themes/attwiz/images/button_startmytrialnow.gif');
     // Create action
     $validator = new RequiredFields('FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PoatalCode', 'Country', 'CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear', 'SubscriptionInfo', 'SubscriptionType');
     $validator = null;
     $form = new Form($this, 'TrialSignupForm', $fields, $actions, $validator);
     $data = Session::get("FormInfo.Form_TrialSignupForm.data");
     if (is_array($data)) {
         $form->loadDataFrom($data);
     }
     return $form;
 }
 function getEditForm($id = null)
 {
     $form = parent::getEditForm($id);
     if (!$id) {
         $id = $this->currentPageID();
     }
     if ($id && is_numeric($id)) {
         $fields = $form->Fields();
         if ($fields->hasTabSet()) {
             $fields->findOrMakeTab('Root.Import', _t('Group.IMPORTTABTITLE', 'Import'));
             $fields->addFieldToTab('Root.Import', new LiteralField('MemberImportFormIframe', sprintf('<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="400px" border="0"></iframe>', $this->Link('memberimport'))));
             if (Permission::check('APPLY_ROLES')) {
                 $fields->addFieldToTab('Root.Roles', new LiteralField('RolesAddEditLink', sprintf('<p class="add-role"><a href="%s">%s</a></p>', $this->Link('show/root'), _t('Group.RolesAddEditLink', 'Add/edit roles'))));
             }
         }
         $form->Actions()->insertBefore($actionAddMember = new FormAction('addmember', _t('SecurityAdmin.ADDMEMBER', 'Add Member')), 'action_save');
         $actionAddMember->setForm($form);
         // Filter permissions
         $permissionField = $form->Fields()->dataFieldByName('Permissions');
         if ($permissionField) {
             $permissionField->setHiddenPermissions(self::$hidden_permissions);
         }
     }
     $this->extend('updateEditForm', $form);
     return $form;
 }
Example #6
0
 function PrepaidSignupForm()
 {
     $cardType = array("visa" => "<img src='themes/attwiz/images/visa.png' height=30px></img>", "mc" => "<img src='themes/attwiz/images/mastercard.jpeg' height=30px></img>", "amex" => "<img src='themes/attwiz/images/ae.jpeg' height=30px></img>", "discover" => "<img src='themes/attwiz/images/discover.jpeg' height=30px></img>");
     $monthArray = array();
     for ($i = 1; $i <= 12; $i++) {
         $monthArray[$i] = date('F', mktime(0, 0, 0, $i));
     }
     $yearArray = array();
     $currentYear = date('Y');
     for ($i = 0; $i <= 10; $i++) {
         $yearArray[$currentYear + $i] = $currentYear + $i;
     }
     $trialExpiryDate = date('F-j-Y', mktime(0, 0, 0, date('n') + 1, date('j'), date('Y')));
     $price = Product::get()->byID(7)->Price;
     $shoppingCart = $this->renderWith('PrepaidShoppingCart', array('Price' => $price));
     $whatsThis = '<span id="WhatsThis"><a id="WhatsThisImage" href="themes/attwiz/images/cvv.jpg" title="What\'s this?">What\'s this?</a></span>';
     $fields = new FieldList(new LiteralField('SignupTitle', '<h2>Create Your Account</h2>'), new EmailField('Email', 'Email'), new ConfirmedPasswordField('Password', 'Password'), new LiteralField('BillingInfoTitle', '<h2>Billing Information</h2>'), new TextField('FirstName', 'First Name'), new TextField('LastName', 'Last Name'), new TextField('Company', 'Company(optional)'), new TextField('StreetAddress1', 'Street Address1'), new TextField('StreetAddress2', 'Street Address2(optional)'), new TextField('City', 'City'), new TextField('State', 'State/Province'), new TextField('PostalCode', 'Zip/Poatal Code'), new CountryDropdownField('Country'), new OptionsetField('CreditCardType', 'Credit Card Type', $cardType, 'visa'), new TextField('NameOnCard', 'Name On Card'), new TextField('CreditCardNumber', 'Credit Card Number'), new PasswordField('CVVCode', 'Security/CVV Code'), new LiteralField('WhatIsThis', $whatsThis), new DropdownField('ExpirationMonth', 'Expiration Date', $monthArray), new DropdownField('ExpirationYear', '', $yearArray), new LiteralField('ShoppingCart', $shoppingCart), new HiddenField('Price', '', $price), new HiddenField('Quantity', '', 1));
     // Create action
     $actions = new FieldList($submit = new FormAction('doPrepaidSignup', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button_purchase.png');
     // Create action
     $validator = new RequiredFields('Email', 'Password', 'FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PoatalCode', 'Country', 'CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear', 'OrderTotal');
     $validator = null;
     return new Form($this, 'PrepaidSignupForm', $fields, $actions, $validator);
 }
 function MemberNonExpiringHeatmapsForm()
 {
     // Get current member
     $member = Member::currentUser();
     $isContactID = $member->ISContactID;
     $subscription = $this->getCurrentSubscription($member->ID);
     switch ($subscription->Product()->ID) {
         case 1:
             $productID = 4;
             break;
         case 2:
             $productID = 5;
             break;
         case 3:
             $productID = 6;
             break;
     }
     $price = Product::get()->byID($productID)->Price;
     $shoppingCart = $this->renderWith('PrepaidShoppingCart', array('Price' => $price));
     // Get existing credit card ID
     $creditCard = $this->getCurrentCreditCard($member->ID);
     if (!$creditCard) {
         $this->setMessage('Error', 'Please update your credit card first.');
         return $this->redirect('/account-settings/#tabs-2');
     }
     $fields = new FieldList(new HiddenField('FirstName', 'First Name', $member->FirstName), new HiddenField('LastName', 'Last Name', $member->Surname), new HiddenField('Company', 'Company(optional)', $creditCard->Company), new HiddenField('StreetAddress1', 'Street Address1', $creditCard->StreetAddress1), new HiddenField('StreetAddress2', 'Street Address2(optional)', $creditCard->StreetAddress2), new HiddenField('City', 'City', $creditCard->City), new HiddenField('State', 'State/Province', $creditCard->State), new HiddenField('PostalCode', 'Zip/Poatal Code', $creditCard->PostalCode), new HiddenField('Country', 'Country', $creditCard->Country), new HiddenField('CreditCardType', 'Credit Card Type', $creditCard->CreditCardType), new HiddenField('NameOnCard', 'Name On Card', $creditCard->NameOnCard), new HiddenField('CreditCardNumber', 'Credit Card Number', $creditCard->CreditCardNumber), new HiddenField('CVVCode', 'Security/CVV Code', $creditCard->CreditCardCVV), new HiddenField('ExpirationMonth', 'Expiration Date', $creditCard->ExpiryMonth), new HiddenField('ExpirationYear', '', $creditCard->ExpiryYear), new LiteralField('ShoppingCart', $shoppingCart), new HiddenField('ProductID', '', $productID), new HiddenField('Price', '', $price), new HiddenField('Quantity', '', 1));
     // Create action
     $actions = new FieldList($submit = new FormAction('doPurchase', 'Purchase Heatmaps'));
     $submit->setAttribute('src', 'themes/attwiz/images/button_purchase.png');
     // Create action
     $validator = new RequiredFields('FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PoatalCode', 'Country', 'CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear');
     return new Form($this, 'MemberNonExpiringHeatmapsForm', $fields, $actions, $validator);
 }
 /**
  * @param FieldSet $actions
  * @parma SiteTree $page
  */
 public static function update_cms_actions(&$actions, $page)
 {
     $openRequest = $page->OpenWorkflowRequest();
     // if user doesn't have publish rights
     if (!$page->canPublish() || $openRequest) {
         // authors shouldn't be able to revert, as this republishes the page.
         // they should rather change the page and re-request publication
         $actions->removeByName('action_revert');
     }
     // Remove the one click publish if they are not an admin/workflow admin.
     if (self::$force_publishers_to_use_workflow && !Permission::checkMember(Member::currentUser(), 'IS_WORKFLOW_ADMIN')) {
         $actions->removeByName('action_publish');
     }
     // Remove the save & publish button if you don't have edit rights
     if (!$page->canEdit()) {
         $actions->removeByName('action_publish');
     }
     $liveVersion = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree_Live\".\"ID\" = {$page->ID}");
     if ($liveVersion && $liveVersion->ExpiryDate != null && $liveVersion->ExpiryDate != '0000-00-00 00:00:00') {
         if ($page->canApprove()) {
             $actions->push(new FormAction('cms_cancelexpiry', _t('WorkflowPublicationRequest.BUTTONCANCELEXPIRY', 'Cancel expiry')));
         }
     }
     // Optional method
     $isPublishable = $page->hasMethod('isPublishable') ? $page->isPublishable() : true;
     if (!$openRequest && $page->canEdit() && $isPublishable && $page->stagesDiffer('Stage', 'Live') && ($page->Version > 1 || $page->Title != "New Page") && !$page->IsDeletedFromStage && (!$page->canPublish() || self::$publisher_can_create_wf_requests)) {
         $actions->push($requestPublicationAction = new FormAction('cms_requestpublication', _t('SiteTreeCMSWorkflow.BUTTONREQUESTPUBLICATION', 'Request Publication')));
         // don't allow creation of a second request by another author
         if (!self::can_create(null, $page)) {
             $actions->makeFieldReadonly($requestPublicationAction->Name());
         }
     }
 }
 function __construct($controller, $name)
 {
     $fields = new FieldList(array($t1 = new TextField('ExternalOrderId', 'Eventbrite Order #'), $checkbox = new CheckboxField('SharedContactInfo', 'Allow to share contact info?')));
     $t1->setAttribute('placeholder', 'Enter your Eventbrite order #');
     $t1->addExtraClass('event-brite-order-number');
     $attendees = Session::get('attendees');
     if (count($attendees) > 0) {
         $t1->setValue(Session::get('ExternalOrderId'));
         $t1->setReadonly(true);
         $checkbox->setValue(intval(Session::get('SharedContactInfo')) === 1);
         $fields->add(new LiteralField('ctrl1', 'Current Order has following registered attendees, please select one:'));
         $options = array();
         foreach ($attendees as $attendee) {
             $ticket_external_id = intval($attendee['ticket_class_id']);
             $ticket_type = SummitTicketType::get()->filter('ExternalId', $ticket_external_id)->first();
             if (is_null($ticket_type)) {
                 continue;
             }
             $options[$attendee['id']] = $attendee['profile']['name'] . ' (' . $ticket_type->Name . ')';
         }
         $attendees_ctrl = new OptionSetField('SelectedAttendee', '', $options);
         $fields->add($attendees_ctrl);
         $validator = new RequiredFields(array('ExternalOrderId'));
         // Create action
         $actions = new FieldList($btn_clear = new FormAction('clearSummitAttendeeInfo', 'Clear'), $btn = new FormAction('saveSummitAttendeeInfo', 'Done'));
         $btn->addExtraClass('btn btn-default active');
         $btn_clear->addExtraClass('btn btn-danger active');
     } else {
         $validator = new RequiredFields(array('ExternalOrderId'));
         // Create action
         $actions = new FieldList($btn = new FormAction('saveSummitAttendeeInfo', 'Get Order'));
         $btn->addExtraClass('btn btn-default active');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('MemberImportForm.Help1', '<p>Import users in <em>CSV format</em> (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
         $helpHtml .= _t('MemberImportForm.Help2', '<div class="advanced">' . '<h4>Advanced usage</h4>' . '<ul>' . '<li>Allowed columns: <em>%s</em></li>' . '<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>' . '</div>');
         $importer = new MemberCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
         $fileField->getValidator()->setAllowedExtensions(array('csv'));
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
         $action->addExtraClass('ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('CsvFile');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/MemberImportForm.js');
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
 /**
  * @return Form|SS_HTTPResponse
  */
 public function EditProfileForm()
 {
     if (!Member::currentUser()) {
         $this->setFlash(_t('EditProfilePage.LoginWarning', 'Please login to edit your profile'), 'warning');
         return $this->redirect(Director::absoluteBaseURL());
     }
     $firstName = new TextField('FirstName');
     $firstName->setAttribute('placeholder', _t('EditProfilePage.FirstNamePlaceholder', 'Enter your first name'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $surname = new TextField('Surname');
     $surname->setAttribute('placeholder', _t('EditProfilePage.SurnamePlaceholder', 'Enter your surname'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $email = new EmailField('Email');
     $email->setAttribute('placeholder', _t('EditProfilePage.EmailPlaceholder', 'Enter your email address'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $jobTitle = new TextField('JobTitle');
     $jobTitle->setAttribute('placeholder', _t('EditProfilePage.JobTitlePlaceholder', 'Enter your job title'))->addExtraClass('form-control');
     $website = new TextField('Website');
     $website->setAttribute('placeholder', _t('EditProfilePage.WebsitePlaceholder', 'Enter your website'))->addExtraClass('form-control');
     $blurb = new TextareaField('Blurb');
     $blurb->setAttribute('placeholder', _t('EditProfilePage.BlurbPlaceholder', 'Enter your blurb'))->addExtraClass('form-control');
     $confirmPassword = new ConfirmedPasswordField('Password', _t('EditProfilePage.PasswordLabel', 'New Password'));
     $confirmPassword->canBeEmpty = true;
     $confirmPassword->setAttribute('placeholder', _t('EditProfilePage.PasswordPlaceholder', 'Enter your password'))->addExtraClass('form-control');
     $fields = new FieldList($firstName, $surname, $email, $jobTitle, $website, $blurb, $confirmPassword);
     $action = new FormAction('SaveProfile', _t('EditProfilePage.SaveProfileText', 'Update Profile'));
     $action->addExtraClass('btn btn-primary btn-lg');
     $actions = new FieldList($action);
     // Create action
     $validator = new RequiredFields('FirstName', 'Email');
     //Create form
     $form = new Form($this, 'EditProfileForm', $fields, $actions, $validator);
     //Populate the form with the current members data
     $Member = Member::currentUser();
     $form->loadDataFrom($Member->data());
     //Return the form
     return $form;
 }
 public function AgeGateForm()
 {
     $enter = new FormAction("EnterAgeGate", "Enter");
     $enter->setUseButtonTag(true);
     $leave = new FormAction("LeaveAgeGate", "Leave");
     $leave->setUseButtonTag(true);
     $form = new Form($this, "AgeGateForm", new FieldList(new TextField("Month", "Month", "MM", 2), new TextField("Day", "Day", "DD", 2), new TextField("Year", "Year", "YYYY", 4), new CheckboxField("itWillBecomeAMemory", "Remember Me")), new FieldList($enter, $leave));
     return $form;
 }
 function __construct($controller, $name)
 {
     $SearchField = new TextField('Search', 'Search');
     $fields = new FieldList($SearchField);
     $searchButton = new FormAction('doSearch', 'Search');
     $searchButton->addExtraClass('button');
     $actions = new FieldList($searchButton);
     parent::__construct($controller, $name, $fields, $actions);
 }
 /**
  * This form is exactly like the CMS form.  It gives us an opportunity to test the fields outside of the CMS context
  */
 function Form()
 {
     $fields = $this->getCMSFields();
     $actions = new FieldList(new FormAction("save", "Save"), $gohome = new FormAction("gohome", "Go home"));
     $gohome->setAttribute('src', 'frameworktest/images/test-button.png');
     $form = new Form($this, "Form", $fields, $actions);
     $form->loadDataFrom($this->dataRecord);
     return $form;
 }
 function __construct($controller, $name)
 {
     $FeedbackField = new TextareaField('Content', 'My Feedback About This Page');
     $fields = new FieldList($FeedbackField);
     $tellUsButton = new FormAction('submitFeedback', 'Tell Us');
     $tellUsButton->addExtraClass('button');
     $actions = new FieldList($tellUsButton);
     parent::__construct($controller, $name, $fields, $actions);
 }
 /**
  * Provide an action button to be clicked per strategy
  * @return FieldList
  */
 protected function getActions()
 {
     $actions = new FieldList();
     foreach ($this->getStrategies() as $strategyClass) {
         $strategyMethod = 'handleStrategy' . $strategyClass;
         $fa = new FormAction($strategyMethod, $strategyClass);
         $fa->setUseButtonTag(true);
         $actions->push($fa);
     }
     return $actions;
 }
Example #17
0
 function RegistrationForm()
 {
     $fields = new FieldList(new EmailField('Email', 'Email'), new ConfirmedPasswordField('Password', 'Password'), new CheckboxField('Terms', 'I agree to the <a href="/customer-login/terms-of-use/" target="_blank">AttentionWizard Terms of Use</a>', 1));
     // Create action
     $actions = new FieldList($submit = new FormAction('doRegister', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button_continue.gif');
     // Create action
     $validator = new RequiredFields('Email', 'Password');
     $form = new Form($this, 'RegistrationForm', $fields, $actions);
     //$form->setTemplate('RegistrationForm');
     return $form;
 }
Example #18
0
 function __construct($controller, $name, $fields, $validator, $readonly, $dataObject)
 {
     $this->dataObject = $dataObject;
     Requirements::clear();
     $actions = new FieldList();
     if (!$readonly) {
         $actions->push($saveAction = new FormAction("saveComplexTableField", "Save"));
         $saveAction->addExtraClass('save');
     }
     $fields->push(new HiddenField("ComplexTableField_Path", Director::absoluteBaseURL()));
     parent::__construct($controller, $name, $fields, $validator, $readonly, $dataObject);
 }
 function Form()
 {
     $query = $this->request->getVar("search");
     $fields = new FieldList(new TextField("search", "", $query));
     $actions = new FieldList($searchaction = new FormAction("index", "Search"));
     $searchaction->setFullAction(null);
     $form = new Form($this, "SearchForm", $fields, $actions);
     $form->setFormAction($this->Link());
     $form->setFormMethod("GET");
     $form->disableSecurityToken();
     return $form;
 }
	function __construct($controller, $name, $fields, $validator, $readonly, $dataObject) {
		$this->dataObject = $dataObject;

		/**
		 * WARNING: DO NOT CHANGE THE ORDER OF THESE JS FILES
		 * Some have special requirements.
		 */
		//Requirements::css(CMS_DIR . 'css/layout.css');
		Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
		Requirements::css(SAPPHIRE_DIR . '/css/ComplexTableField_popup.css');
		Requirements::css(CMS_DIR . '/css/typography.css');
		Requirements::css(CMS_DIR . '/css/cms_right.css');
		Requirements::css(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.css');
		Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
		Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
		Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
		Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/scriptaculous.js");
		Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
		Requirements::javascript(THIRDPARTY_DIR . "/layout_helpers.js");
		Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain.js");
		Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_right.js");
		Requirements::javascript(SAPPHIRE_DIR . "/javascript/TableField.js");
		Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
		Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField_popup.js");
		// jQuery requirements (how many of these are actually needed?)
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.core.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.tabs.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/form/jquery.form.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/dimensions/jquery.dimensions.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.js');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/ScaffoldComplexTableField.js');
		Requirements::javascript(CMS_DIR . '/javascript/ModelAdmin.js');
		
 		if($this->dataObject->hasMethod('getRequirementsForPopup')) {
			$this->dataObject->getRequirementsForPopup();
		}
		
		$actions = new FieldSet();	
		if(!$readonly) {
			$actions->push(
				$saveAction = new FormAction("saveComplexTableField", "Save")
			);	
			$saveAction->addExtraClass('save');
		}
		
		$fields->push(new HiddenField("ComplexTableField_Path", Director::absoluteBaseURL()));
		
		parent::__construct($controller, $name, $fields, $actions, $validator);
	}
 function ContactForm()
 {
     // Create fields
     $fields = new FieldList(TextField::create('Name')->setTitle(_t('ContactPage.NAMEINPUT', "Name <em>*</em>")), TextField::create("Cellphone")->setTitle(_t('ContactPage.CELLPHONE', "Cellphone")), EmailField::create("Email")->setTitle(_t('ContactPage.EMAIL', "Email address"))->setAttribute('type', 'email'), TextareaField::create("Question")->setTitle(_t('ContactPage.QUESTION', "Question <em>*</em>")));
     $this->extend('updateContactForm', $fields);
     // Create action
     $send = new FormAction('SendContactForm', _t('ContactPage.SEND', "Send"));
     $send->addExtraClass("success btn");
     $actions = new FieldList($send);
     // Create action
     $validator = new RequiredFields('Name', 'Email', 'Question');
     return new Form($this, 'ContactForm', $fields, $actions, $validator);
 }
Example #22
0
    function CancelSubscriptionForm()
    {
        $reasons = array("I didn't use the product as much as I anticipated" => "I didn't use the product as much as I anticipated", "The cost was too high" => "The cost was too high", "I had technical problems generating heatmaps" => "I had technical problems generating heatmaps", "I have changed jobs/careers" => "I have changed jobs/careers", "I had problems with customer service" => "I had problems with customer service", "I didn't find the heatmaps helpful" => "I didn't find the heatmaps helpful", "Other (you may contact us support@attentionwizard.com with additional feedback)" => "Other (you may contact us support@attentionwizard.com with additional feedback)");
        $info = '<p>Please remember, you can continue to purchase non-expiring heatmaps and access your heatmap inventory. Your account will remain open and available to you even after your subscription is cancelled.</p>
				<p>&nbsp;</p>
<p style="font-style:italic;">Note: accounts with no activity for a 60-day period may be closed, and heatmaps associated with the account purged.If you wish to completely close your account please email <a href="mailto:support@attentionwizard.com">support@attentionwizard.com</a></p>
				';
        $fields = new FieldList(new CheckboxSetField('Reasons', '', $reasons), new LiteralField('Info', $info));
        // Create action
        $actions = new FieldList($submit = new FormAction('cancelSubscription', ''));
        $submit->setAttribute('src', 'themes/attwiz/images/button_cancel_sub.png');
        // Create action
        $validator = new RequiredFields('Reasons');
        return new Form($this, 'CancelSubscriptionForm', $fields, $actions, $validator);
    }
Example #23
0
 public function getCMSActions()
 {
     $actions = parent::getCMSActions();
     $addCreditCard = new FormAction('addCreditCard', 'Add Credit Card');
     $addCreditCard->addExtraClass('ss-ui-action-constructive');
     $updateCreditCard = new FormAction('updateCreditCard', 'Update Credit Card');
     $updateCreditCard->addExtraClass('ss-ui-action-constructive');
     if ($this->ID) {
         $actions->push($updateCreditCard);
     }
     if (!$this->ID) {
         $actions->push($addCreditCard);
     }
     return $actions;
 }
Example #24
0
 public function CreateHeatmapForm()
 {
     $includeWatermark = array("1" => "Yes,Include Watermark", "0" => "No,Remove Watermark");
     $fields = new FieldList($imageField = new FileField('OriginalImage', 'Upload an Image File'), new LiteralField('UploadInfo', 'Acceptable images are jpg or png, 500-1600 pixels wide by 500-1200 pixels height.<hr>'), new OptionsetField('IncludeWatermark', 'Include Watermark?', $includeWatermark, 1));
     $imageField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png'));
     $imageField->setAttribute('class', 'jfilestyle');
     $imageField->setAttribute('data-buttonText', "<img src='themes/attwiz/images/button-create-heatmap-browse.jpg'></img>");
     $imageField->setAttribute('data-placeholder', 'No file selected..');
     // Create action
     $actions = new FieldList($submit = new FormAction('processCreateHeatmap', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button-create-heatmap-blue-bg.jpg');
     // Create action
     $validator = new RequiredFields('OriginalImage', 'IncludeWatermark');
     return new Form($this, 'CreateHeatmapForm', $fields, $actions, $validator);
 }
 public function __construct($controller, $name)
 {
     $member = Member::currentUser();
     $requiredFields = null;
     if ($member && $member->exists()) {
         $fields = $member->getMemberFormFields();
         $fields->removeByName('Password');
         //TODO: This can be reverted to be $member->getValidator() as soon as this fix lands in framework
         // (most likely 3.4) https://github.com/silverstripe/silverstripe-framework/pull/5098
         $requiredFields = ShopAccountFormValidator::create();
         $requiredFields->addRequiredField('Surname');
     } else {
         $fields = FieldList::create();
     }
     if (get_class($controller) == 'AccountPage_Controller') {
         $actions = FieldList::create(FormAction::create('submit', _t('MemberForm.Save', 'Save Changes')));
     } else {
         $actions = FieldList::create(FormAction::create('submit', _t('MemberForm.Save', 'Save Changes')), FormAction::create('proceed', _t('MemberForm.SaveAndProceed', 'Save and proceed to checkout')));
     }
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     $this->extend('updateShopAccountForm');
     if ($member) {
         $member->Password = "";
         //prevents password field from being populated with encrypted password data
         $this->loadDataFrom($member);
     }
 }
Example #26
0
 /**
  * @param Controller $controller
  * @param String $name
  * @param array $arguments
  */
 public function __construct($controller, $name, $arguments = array())
 {
     /** =========================================
          * @var EmailField $emailField
          * @var TextField $nameField
          * @var FormAction $submit
          * @var Form $form
         ===========================================*/
     /** -----------------------------------------
      * Fields
      * ----------------------------------------*/
     $emailField = EmailField::create('Email', 'Email Address');
     $emailField->addExtraClass('form-control')->setAttribute('placeholder', 'Email')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>');
     $nameField = TextField::create('Name', 'Name');
     $nameField->setAttribute('placeholder', 'Name')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Name</strong>')->setCustomValidationMessage('Please enter your <strong>Name</strong>');
     $fields = FieldList::create($nameField, $emailField);
     /** -----------------------------------------
      * Actions
      * ----------------------------------------*/
     $submit = FormAction::create('Subscribe');
     $submit->setTitle('SIGN UP')->addExtraClass('button');
     $actions = FieldList::create($submit);
     /** -----------------------------------------
      * Validation
      * ----------------------------------------*/
     $required = RequiredFields::create('Name', 'Email');
     $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');
 }
 function SelectForm()
 {
     $fieldList = new FieldList(NumericField::create("Year", "Manufacturing Year"), DropdownField::create("Make", "Make", array(0 => $this->pleaseSelectPhrase())), DropdownField::create("Model", "Model", array(0 => $this->pleaseSelectPhrase())), DropdownField::create("Type", "Type", array(0 => $this->pleaseSelectPhrase())), NumericField::create("ODO", "Current Odometer (overall distance travelled - as shown in your dashboard"));
     $actions = new FieldList(FormAction::create("doselectform")->setTitle("Start Calculation"));
     $form = Form::create($this, "SelectForm", $fieldList, $actions);
     return $form;
 }
 private function Form()
 {
     $fields = FieldList::create(TextField::create('Title'), TextField::create('Subtitle'));
     $actions = FieldList::create(FormAction::create('submit', 'submit'));
     $validator = ZenValidator::create();
     return Form::create(Controller::curr(), 'Form', $fields, $actions, $validator);
 }
 public function AddNewListboxForm()
 {
     $action = FormAction::create('doSave', 'Save')->setUseButtonTag('true');
     if (!$this->isFrontend) {
         $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept');
     }
     $model = $this->getModel();
     $link = singleton($model);
     $fields = $link->getCMSFields();
     $title = $this->getDialogTitle() ? $this->getDialogTitle() : 'New Item';
     $fields->insertBefore(HeaderField::create('AddNewHeader', $title), $fields->first()->getName());
     $actions = FieldList::create($action);
     $form = Form::create($this, 'AddNewListboxForm', $fields, $actions);
     $fields->push(HiddenField::create('model', 'model', $model));
     /*
     if($link){
     	$form->loadDataFrom($link);
     	$fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID));
     }
     
     // Chris Bolt, fixed this
     //$this->owner->extend('updateLinkForm', $form);
     $this->extend('updateLinkForm', $form);
     // End Chris Bolt
     */
     return $form;
 }
 public function getEditForm($id = null, $fields = null)
 {
     $tabs = new TabSet('Root', new Tab('Main'));
     $fields = new FieldList($tabs);
     $caches = array();
     $all_caches = SimpleCache::$cache_configs;
     foreach ($all_caches as $name => $cacheInfo) {
         $cache = $this->getCache($name);
         if ($cache) {
             $stats = $cache->stats();
             $fields->addFieldToTab('Root.Info', new HeaderField($name . 'header', $name));
             $fields->addFieldToTab('Root.Info', new ReadonlyField($name . 'Hits', 'Hits', $stats->hits));
             $fields->addFieldToTab('Root.Info', new ReadonlyField($name . 'Miss', 'Miss', $stats->misses));
             $fields->addFieldToTab('Root.Info', new ReadonlyField($name . 'Count', 'Count', $stats->count));
             $caches[$name] = $name;
         }
     }
     if (count($caches)) {
         $fields->addFieldToTab('Root.Main', new CheckboxSetField('ToClear', 'Caches to clear', $caches));
         $fields->addFieldToTab('Root.Main', new TextField('Key', 'Key to clear from selected caches'));
     }
     $actions = new FieldList(FormAction::create('clear', 'Clear')->setUseButtonTag(true));
     $form = CMSForm::create($this, "EditForm", $fields, $actions)->setHTMLID('Form_EditForm');
     $form->addExtraClass('cms-edit-form center');
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->setTemplate('SimpleCacheAdmin_EditForm');
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     return $form;
 }