/** * 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 __construct($controller, $name = "CreateOrganisationForm") { $fields = $this->getOrganisationFields(); $actions = new FieldList(FormAction::create("docreate", "Create")); $validator = new OrganisationFormValidator('Name'); parent::__construct($controller, $name, $fields, $actions, $validator); }
/** * @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'); }
/** * Provides a GUI for the insert/edit shortcode popup * @return Form **/ public function ShortcodeForm() { if (!Permission::check('CMS_ACCESS_CMSMain')) { return; } Config::inst()->update('SSViewer', 'theme_enabled', false); // create a list of shortcodable classes for the ShortcodeType dropdown $classList = ClassInfo::implementorsOf('Shortcodable'); $classes = array(); foreach ($classList as $class) { $classes[$class] = singleton($class)->singular_name(); } // load from the currently selected ShortcodeType or Shortcode data $classname = false; $shortcodeData = false; if ($shortcode = $this->request->requestVar('Shortcode')) { $shortcode = str_replace("", '', $shortcode); //remove BOM inside string on cursor position... $shortcodeData = singleton('ShortcodableParser')->the_shortcodes(array(), $shortcode); if (isset($shortcodeData[0])) { $shortcodeData = $shortcodeData[0]; $classname = $shortcodeData['name']; } } else { $classname = $this->request->requestVar('ShortcodeType'); } if ($shortcodeData) { $headingText = _t('Shortcodable.EDITSHORTCODE', 'Edit Shortcode'); } else { $headingText = _t('Shortcodable.INSERTSHORTCODE', 'Insert Shortcode'); } // essential fields $fields = FieldList::create(array(CompositeField::create(LiteralField::create('Heading', sprintf('<h3 class="htmleditorfield-shortcodeform-heading insert">%s</h3>', $headingText)))->addExtraClass('CompositeField composite cms-content-header nolabel'), LiteralField::create('shortcodablefields', '<div class="ss-shortcodable content">'), DropdownField::create('ShortcodeType', 'ShortcodeType', $classes, $classname)->setHasEmptyDefault(true)->addExtraClass('shortcode-type'))); // attribute and object id fields if ($classname) { if (class_exists($classname)) { $class = singleton($classname); if (is_subclass_of($class, 'DataObject')) { if (singleton($classname)->hasMethod('get_shortcodable_records')) { $dataObjectSource = $classname::get_shortcodable_records(); } else { $dataObjectSource = $classname::get()->map()->toArray(); } $fields->push(DropdownField::create('id', $class->singular_name(), $dataObjectSource)->setHasEmptyDefault(true)); } if ($attrFields = $classname::shortcode_attribute_fields()) { $fields->push(CompositeField::create($attrFields)->addExtraClass('attributes-composite')); } } } // actions $actions = FieldList::create(array(FormAction::create('insert', _t('Shortcodable.BUTTONINSERTSHORTCODE', 'Insert shortcode'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true))); // form $form = Form::create($this, "ShortcodeForm", $fields, $actions)->loadDataFrom($this)->addExtraClass('htmleditorfield-form htmleditorfield-shortcodable cms-dialog-content'); if ($shortcodeData) { $form->loadDataFrom($shortcodeData['atts']); } $this->extend('updateShortcodeForm', $form); return $form; }
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; }
/** * A simple form for creating blog entries */ function FrontEndPostForm() { if ($this->owner->request->latestParam('ID')) { $id = (int) $this->owner->request->latestParam('ID'); } else { $id = 0; } $membername = Member::currentUser() ? Member::currentUser()->getName() : ""; // Set image upload $uploadfield = UploadField::create('FeaturedImage', _t('BlogFrontEnd.ShareImage', "Share an image")); $uploadfield->setCanAttachExisting(false); $uploadfield->setCanPreviewFolder(false); $uploadfield->setAllowedFileCategories('image'); $uploadfield->relationAutoSetting = false; if (BlogFrontEnd::config()->allow_wysiwyg_editing) { $content_field = TrumbowygHTMLEditorField::create("Content", _t("BlogFrontEnd.Content")); } else { $content_field = TextareaField::create("Content", _t("BlogFrontEnd.Content")); } $form = new Form($this->owner, 'FrontEndPostForm', $fields = new FieldList(HiddenField::create("ID", "ID"), TextField::create("Title", _t('BlogFrontEnd.Title', "Title")), $uploadfield, $content_field), $actions = new FieldList(FormAction::create('doSavePost', _t('BlogFrontEnd.PostEntry', 'Post Entry'))), new RequiredFields('Title')); $uploadfield->setForm($form); if ($this->owner->Categories()->exists()) { $fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.PostUnderCategories", "Post this in a category? (optional)"), $this->owner->Categories()->map())); } if ($this->owner->Tags()->exists()) { $fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.AddTags", "Add a tag? (optional)"), $this->owner->Tags()->map())); } if ($id && ($post = BlogPost::get()->byID($id))) { $form->loadDataFrom($post); } $this->owner->extend("updateFrontEndPostForm", $form); return $form; }
/** * @return Form */ public function ItemEditForm() { if (!$this->record->isPublished()) { Versioned::reading_stage('Stage'); } if (!$this->record->ParentID) { // set a parent id for the record, even if it will change $parents = $this->record->getCatalogParents(); if ($parents && $parents->count()) { $this->record->ParentID = $parents->first()->ID; } } $form = parent::ItemEditForm(); if ($this->record->has_extension('CatalogPageExtension') || $this->record->has_extension('CatalogDataObjectExtension')) { $actions = $form->Actions(); if ($this->record->ID) { if ($this->record->isPublished()) { $actions->push(FormAction::create('doDisable', _t('CatalogManager.DISABLE', 'Disable'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-destructive')); } else { $actions->push(FormAction::create('doEnable', _t('CatalogManager.ENABLE', 'Enable'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')); } } if ($this->record->canCreate() && $this->record->stat('can_duplicate') == true) { $actions->push(FormAction::create('doDuplicate', _t('CatalogManager.DUPLICATE', 'Duplicate'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')); } $form->setActions($actions); } $this->extend('updateItemEditForm', $form); return $form; }
public function __construct($controller, $name) { $member = Member::currentUser(); $requiredFields = null; if ($member && $member->exists()) { $fields = $member->getMemberFormFields(); $fields->removeByName('Password'); $requiredFields = $member->getValidator(); $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 ($record = $controller->data()) { $record->extend('updateShopAccountForm', $fields, $actions, $requiredFields); } if ($controller->data() && $controller->data()->hasMethod('updateShopAccountForm')) { // if accessing through the model Deprecation::notice('2.0', 'Please access updateShopAccountForm through ShopAccountForm instead of AccountPage (this extension point is due to be removed)'); } if ($member) { $member->Password = ""; //prevents password field from being populated with encrypted password data $this->loadDataFrom($member); } }
public function UpdateForm() { $member = singleton('SecurityContext')->getMember(); if (!$member) { return ''; } // if there's a member profile page availble, use it $filter = array(); if (class_exists('Multisites')) { $filter = array('SiteID' => Multisites::inst()->getCurrentSiteId()); } // use member profile page if possible if (class_exists('MemberProfilePage') && ($profilePage = MemberProfilePage::get()->filter($filter)->first())) { $controller = MemberProfilePage_Controller::create($profilePage); $form = $controller->ProfileForm(); $form->addExtraClass('ajax-form'); $form->loadDataFrom($member); return $form; } else { $password = new ConfirmedPasswordField('Password', $member->fieldLabel('Password'), null, null, (bool) $this->ID); $password->setCanBeEmpty(true); $fields = FieldList::create(TextField::create('FirstName', $member->fieldLabel('FirstName')), TextField::create('Surname', $member->fieldLabel('Surname')), EmailField::create('Email', $member->fieldLabel('Email')), $password); $actions = FieldList::create($update = FormAction::create('updateprofile', 'Update')); $form = Form::create($this, 'UpdateForm', $fields, $actions); $form->loadDataFrom($member); $this->extend('updateProfileDashletForm', $form); return $form; } return; }
/** * 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')); }
/** * @param IRSVPTemplate $template * @param IRSVP $rsvp * @param ISummitEvent $event * @param string $form_name * @return BootstrapForm|PresentationSpeaker */ public function build(IRSVPTemplate $template, IRSVP $rsvp, ISummitEvent $event, $form_name = 'RSVPForm') { $fields = new FieldList(); foreach ($template->getQuestions() as $q) { $type = $q->Type(); $builder_class = $type . 'UIBuilder'; // @IRSVPQuestionTemplateUIBuilder $builder = Injector::inst()->create($builder_class); $answer = $rsvp ? $rsvp->findAnswerByQuestion($q) : null; $field = $builder->build($rsvp, $q, $answer); $fields->add($field); } $validator = null; if ($rsvp) { $fields->add(new HiddenField('rsvp_id', 'rsvp_id', $rsvp->getIdentifier())); } $fields->add(new HiddenField('event_id', 'event_id', $event->getIdentifier())); $fields->add(new HiddenField('summit_id', 'summit_id', $event->Summit()->getIdentifier())); $fields->add(new HiddenField('seat_type', 'seat_type', $event->getCurrentRSVPSubmissionSeatType())); $fields->add(new LiteralField('hr', '<hr>')); $actions = new FieldList(FormAction::create('submit_rsvp')->setTitle('Send RSVP')->addExtraClass('rsvp_submit')); $form = new BootstrapForm(Controller::curr(), $form_name . '_' . $event->getIdentifier(), $fields, $actions, $validator); $form->setAttribute('class', 'rsvp_form'); return $form; }
/** * @param Controller $controller * @param String $name * @param array $arguments */ public function __construct($controller, $name, $arguments = array()) { /** ----------------------------------------- * Fields * ----------------------------------------*/ /** @var EmailField $email */ $email = EmailField::create('Email', 'Email Address'); $email->addExtraClass('form-control')->setAttribute('data-parsley-required-message', 'Please enter your <strong>Email</strong>')->setCustomValidationMessage('Please enter your <strong>Email</strong>'); $fields = FieldList::create($email); /** ----------------------------------------- * Actions * ----------------------------------------*/ $actions = FieldList::create(FormAction::create('Subscribe')->setTitle('Subscribe')->addExtraClass('btn btn-primary')); /** ----------------------------------------- * Validation * ----------------------------------------*/ $required = RequiredFields::create('Email'); /** @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'); }
/** * @return Form */ public function AddForm() { $fields = new FieldList(new LiteralField('SelectFieldType', '<p><strong>Please select a field type to add:</strong></p>'), $df = new DropdownField('ClassName', '', $this->getFieldTypes(), null, null)); $df->setHasEmptyDefault(true); if ($schemaID = (int) $this->request->param('ID')) { $fields->push(new HiddenField('SchemaID', '', $schemaID)); } $actions = new FieldList(FormAction::create('doAddField', 'Create')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')); // Add a Cancel link which is a button-like link and link back to one level up. $curmbs = $this->Breadcrumbs(); if ($curmbs && $curmbs->count() >= 2) { $one_level_up = $curmbs->offsetGet($curmbs->count() - 2); $text = "\n\t\t\t<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"" . $one_level_up->Link . "\">\n\t\t\t\tCancel\n\t\t\t</a>"; $actions->push(new LiteralField('cancelbutton', $text)); } $form = new Form($this, 'AddForm', $fields, $actions); $toplevelController = $this->getToplevelController(); $form->setTemplate('LeftAndMain_EditForm'); $form->addExtraClass('cms-content cms-edit-form center ss-tabset stacked'); $form->setAttribute('data-pjax-fragment', 'CurrentForm Content'); if ($form->Fields()->hasTabset()) { $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); } //var_dump($this->popupController); die; $parents = $this->popupController->Breadcrumbs(false)->items; $form->Backlink = array_pop($parents)->Link; return $form; }
public function updateItemEditForm($form) { if ($this->owner->record->ClassName !== 'Application') { return $form; } $actions = $form->Actions(); $canSubmitOrg = $this->owner->record->canSubmitOrg(); $canReturnRevising = $this->owner->record->canReturnRevising(); $canOfficeApprove = $this->owner->record->canOfficeApprove(); $canAdminApprove = $this->owner->record->canAdminApprove(); $canInitiate = $this->owner->record->canInitiate(); $canFail = $this->owner->record->canFail(); if ($canSubmitOrg) { $actions->push(FormAction::create('doSubmitOrg', '上报企业')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')); } if ($canOfficeApprove) { $actions->push(FormAction::create('doOfficeApprove', '初审通过')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')); } if ($canAdminApprove) { $actions->push(FormAction::create('doAdminApprove', '审核通过')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')); } if ($canReturnRevising) { $actions->push(FormAction::create('doReturnRevising', '退回修改')->setUseButtonTag(true)->addExtraClass('ss-ui-action-destructive')); } if ($canInitiate) { $actions->push(FormAction::create('doInitiate', '立项')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')); } if ($canFail) { $actions->push(FormAction::create('doFail', '审核落选')->setUseButtonTag(true)->addExtraClass('ss-ui-action-destructive')); } }
public function BillingAddressForm() { $form = CheckoutForm::create($this->owner, 'BillingAddressForm', $this->billingconfig()); $form->setActions(FieldList::create(FormAction::create("setbillingaddress", _t('CheckoutStep.Continue', "Continue")))); $this->owner->extend('updateBillingAddressForm', $form); return $form; }
public function updateEditForm(Form $form) { $sng = singleton($this->modelClass()); if ($sng->hasExtension('ScriptGenieExtension')) { $form->Actions()->push(FormAction::create('regenerate', 'Regenerate Data')); } }
public function __construct($controller, $name = "CartForm", $cart = null, $template = "Cart") { $this->cart = $cart; $fields = new FieldList(CartEditField::create("Items", "", $this->cart)->setTemplate($template)); $actions = new FieldList(FormAction::create("updatecart", "Update Cart")); parent::__construct($controller, $name, $fields, $actions); }
public function index() { $site = SiteConfig::current_site_config(); $order = $this->order; // Setup the paypal gateway URL if (Director::isDev()) { $gateway_url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; } else { $gateway_url = "https://www.paypal.com/cgi-bin/webscr"; } $callback_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, "callback", $this->payment_gateway->ID); $success_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete'); $error_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete', 'error'); $back_url = Controller::join_links(Director::absoluteBaseURL(), Checkout_Controller::config()->url_segment, "finish"); $fields = new FieldList(HiddenField::create('business', null, $this->payment_gateway->BusinessID), HiddenField::create('item_name', null, $site->Title), HiddenField::create('cmd', null, "_cart"), HiddenField::create('paymentaction', null, "sale"), HiddenField::create('invoice', null, $order->OrderNumber), HiddenField::create('custom', null, $order->OrderNumber), HiddenField::create('upload', null, 1), HiddenField::create('discount_amount_cart', null, $order->DiscountAmount), HiddenField::create('amount', null, $order->Total), HiddenField::create('currency_code', null, $site->Currency()->GatewayCode), HiddenField::create('first_name', null, $order->FirstName), HiddenField::create('last_name', null, $order->Surname), HiddenField::create('address1', null, $order->Address1), HiddenField::create('address2', null, $order->Address2), HiddenField::create('city', null, $order->City), HiddenField::create('zip', null, $order->PostCode), HiddenField::create('country', null, $order->Country), HiddenField::create('email', null, $order->Email), HiddenField::create('return', null, $success_url), HiddenField::create('notify_url', null, $callback_url), HiddenField::create('cancel_return', null, $error_url)); $i = 1; foreach ($order->Items() as $item) { $fields->add(HiddenField::create('item_name_' . $i, null, $item->Title)); $fields->add(HiddenField::create('amount_' . $i, null, number_format($item->Price + $item->Tax, 2))); $fields->add(HiddenField::create('quantity_' . $i, null, $item->Quantity)); $i++; } // Add shipping as an extra product $fields->add(HiddenField::create('item_name_' . $i, null, _t("Commerce.Postage", "Postage"))); $fields->add(HiddenField::create('amount_' . $i, null, number_format($order->PostageCost + $order->PostageTax, 2))); $fields->add(HiddenField::create('quantity_' . $i, null, "1")); $actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red commerce-action-back">' . _t('Commerce.Back', 'Back') . '</a>'), FormAction::create('Submit', _t('Commerce.ConfirmPay', 'Confirm and Pay'))->addExtraClass('btn')->addExtraClass('btn-green')); $form = Form::create($this, 'Form', $fields, $actions)->addExtraClass('forms')->setFormMethod('POST')->setFormAction($gateway_url); $this->extend('updateForm', $form); return array("Title" => _t('Commerce.CheckoutSummary', "Summary"), "MetaTitle" => _t('Commerce.CheckoutSummary', "Summary"), "Form" => $form); }
protected function getFormActions() { $actions = parent::getFormActions(); // Check if record is versionable $record = $this->getRecord(); if (!$record || !$record->has_extension('Versioned')) { return $actions; } // Save & Publish action if ($record->canPublish()) { // "publish", as with "save", it supports an alternate state to show when action is needed. $publish = FormAction::create('doPublish', _t('VersionedGridFieldItemRequest.BUTTONPUBLISH', 'Publish'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'); // Insert after save if ($actions->fieldByName('action_doSave')) { $actions->insertAfter('action_doSave', $publish); } else { $actions->push($publish); } } // Unpublish action $isPublished = $record->isPublished(); if ($isPublished && $record->canUnpublish()) { $actions->push(FormAction::create('doUnpublish', _t('VersionedGridFieldItemRequest.BUTTONUNPUBLISH', 'Unpublish'))->setUseButtonTag(true)->setDescription(_t('VersionedGridFieldItemRequest.BUTTONUNPUBLISHDESC', 'Remove this record from the published site'))->addExtraClass('ss-ui-action-destructive')); } // Archive action if ($record->canArchive()) { // Replace "delete" action $actions->removeByName('action_doDelete'); // "archive" $actions->push(FormAction::create('doArchive', _t('VersionedGridFieldItemRequest.ARCHIVE', 'Archive'))->setDescription(_t('VersionedGridFieldItemRequest.BUTTONARCHIVEDESC', 'Unpublish and send to archive'))->addExtraClass('delete ss-ui-action-destructive')); } return $actions; }
public function PaymentMethodForm() { $form = CheckoutForm::create($this->owner, "PaymentMethodForm", $this->checkoutconfig()); $form->setActions(FieldList::create(FormAction::create("setpaymentmethod", _t('CheckoutStep.Continue', "Continue")))); $this->owner->extend('updatePaymentMethodForm', $form); return $form; }
/** * The LinkForm for the dialog window * * @return Form **/ public function LinkForm() { $link = $this->getLinkObject(); $action = FormAction::create('doSaveLink', _t('Linkable.SAVE', 'Save'))->setUseButtonTag('true'); if (!$this->isFrontend) { $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'); } $link = null; if ($linkID = (int) $this->request->getVar('LinkID')) { $link = Link::get()->byID($linkID); } $link = $link ? $link : singleton('Link'); $link->setAllowedTypes($this->getAllowedTypes()); $fields = $link->getCMSFields(); $title = $link ? _t('Linkable.EDITLINK', 'Edit Link') : _t('Linkable.ADDLINK', 'Add Link'); $fields->insertBefore(HeaderField::create('LinkHeader', $title), _t('Linkable.TITLE', 'Title')); $actions = FieldList::create($action); $form = Form::create($this, 'LinkForm', $fields, $actions); if ($link) { $form->loadDataFrom($link); $fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID)); } $this->owner->extend('updateLinkForm', $form); return $form; }
/** * @return Form */ public function ItemEditForm() { VersionedReadingMode::setStageReadingMode(); $form = parent::ItemEditForm(); /* @var $actions FieldList */ if ($form instanceof Form) { $actions = $form->Actions(); $actions->replaceField('action_doSave', FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true)); $published = $this->record->isPublished(); /* @var $publish FormAction */ $publish = FormAction::create('publish', $published ? _t('SiteTree.BUTTONPUBLISHED', 'Published') : _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true); if ($this->record->stagesDiffer('Stage', 'Live') && $published) { $publish->addExtraClass('ss-ui-alternate'); $actions->push(FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'))->setDescription(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page'))); } $actions->push($publish); if ($published) { /* @var $unpublish FormAction */ $unpublish = FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'))->addExtraClass('ss-ui-action-destructive'); $actions->push($unpublish); $actions->removeByName('action_doDelete'); } } VersionedReadingMode::restoreOriginalReadingMode(); 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; }
/** * Return the payment form */ public function PayForm() { $request = $this->getRequest(); $response = Session::get('EwayResponse'); $months = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'); $years = range(date('y'), date('y') + 10); //Note: years beginning with 0 might cause issues $amount = $response->Payment->TotalAmount; $amount = number_format($amount / 100, 2); $currency = $response->Payment->CurrencyCode; $fields = new FieldList(HiddenField::create('EWAY_ACCESSCODE', '', $response->AccessCode), TextField::create('PayAmount', 'Amount', $amount . ' ' . $currency)->setDisabled(true), $nameField = TextField::create('EWAY_CARDNAME', 'Card holder'), $numberField = TextField::create('EWAY_CARDNUMBER', 'Card Number'), $expMonthField = DropdownField::create('EWAY_CARDEXPIRYMONTH', 'Expiry Month', array_combine($months, $months)), $expYearField = DropdownField::create('EWAY_CARDEXPIRYYEAR', 'Expiry Year', array_combine($years, $years)), $cvnField = TextField::create('EWAY_CARDCVN', 'CVN Number'), HiddenField::create('FormActionURL', '', $response->FormActionURL)); //Test data if (Director::isDev()) { $nameField->setValue('Test User'); $numberField->setValue('4444333322221111'); $expMonthField->setValue('12'); $expYearField->setValue(date('y') + 1); $cvnField->setValue('123'); } $actions = new FieldList(FormAction::create('', 'Process')); $form = new Form($this, 'PayForm', $fields, $actions); $form->setFormAction($response->FormActionURL); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript('payment-eway/javascript/eway-form.js'); $this->extend('updatePayForm', $form); 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); }
/** * @param Controller $controller * @param String $method * @param string $suggestURL */ public function __construct($controller, $method, $suggestURL = '') { $searchField = TextField::create('q', ''); $searchField->setAttribute('placeholder', _t('ShopSearch.SEARCH', 'Search')); if ($suggestURL) { $searchField->setAttribute('data-suggest-url', $suggestURL); } $fields = FieldList::create($searchField); if (!self::config()->disable_category_dropdown) { $cats = ShopSearch::get_category_hierarchy(0, '', self::config()->category_max_depth); $catField = DropdownField::create(self::get_category_field(), '', $cats, Session::get('LastSearchCatID')); $emptyString = self::config()->category_empty_string; if ($emptyString !== 'NONE') { $catField->setEmptyString(_t('ShopSearch.' . $emptyString, $emptyString)); } $fields->push($catField); } parent::__construct($controller, $method, $fields, FieldList::create(array(FormAction::create('results', _t('ShopSearch.GO', 'Go'))))); $this->setFormMethod('GET'); $this->disableSecurityToken(); if ($c = self::config()->css_classes) { $this->addExtraClass($c); } Requirements::css(SHOP_SEARCH_FOLDER . '/css/ShopSearch.css'); if (Config::inst()->get('ShopSearch', 'suggest_enabled')) { Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js'); Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::javascript(SHOP_SEARCH_FOLDER . '/javascript/search.suggest.js'); Requirements::javascript(SHOP_SEARCH_FOLDER . '/javascript/search.js'); } }
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; }
public function __construct($controller, $name, $fields = null, $actions = null) { $fields = new FieldList($Email = EmailField::create('Email')->setTitle(_t('ContactForm.EMAIL', 'ContactForm.EMAIL')), $Name = TextField::create('Name')->setTitle(_t('ContactForm.NAME', 'ContactForm.NAME')), $Message = TextareaField::create('Message')->setTitle(_t('ContactForm.MESSAGE', 'ContactForm.MESSAGE'))); $actions = new FieldList($Submit = FormAction::create('doContact')->setTitle(_t('ContactForm.BUTTONSEND', 'ContactForm.BUTTONSEND'))); $Submit->addExtraClass('btn'); parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Email", "Name", "Message")); }
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); } }
private function buildForm() { $contact_fields = $this->ContactFields(); $fields = new FieldList(); $required_fields = array(); foreach ($contact_fields as $contact_field) { switch ($contact_field->Type) { case 'TextField': $fields->add(new TextField($contact_field->Name, $contact_field->Name)); break; case 'EmailField': $fields->add(new EmailField($contact_field->Name, $contact_field->Name)); break; case 'TextareaField': $fields->add(new TextareaField($contact_field->Name, $contact_field->Name)); break; case 'DropdownField': $values = explode("\n", $contact_field->Values); $dropdown_values = array(); foreach ($values as $value) { $dropdown_values[trim($value)] = trim($value); } $fields->add(new DropdownField($contact_field->Name, $contact_field->Name, $dropdown_values)); break; } if ($contact_field->Required) { $required_fields[] = $contact_field->Name; } } $actions = new FieldList(FormAction::create("doSubmitContactForm")->setTitle("Contact")); $required = new RequiredFields($required_fields); $form = new Form($this, 'ContactForm', $fields, $actions, $required); return $form; }