public function __construct($controller, $name, Order $order)
 {
     $this->order = $order;
     $fields = FieldList::create(HiddenField::create('OrderID', '', $order->ID));
     $actions = FieldList::create();
     //payment
     if (self::config()->allow_paying && $order->canPay()) {
         $gateways = GatewayInfo::get_supported_gateways();
         //remove manual gateways
         foreach ($gateways as $gateway => $gatewayname) {
             if (GatewayInfo::is_manual($gateway)) {
                 unset($gateways[$gateway]);
             }
         }
         if (!empty($gateways)) {
             $fields->push(HeaderField::create("MakePaymentHeader", _t("OrderActionsForm.MAKEPAYMENT", "Make Payment")));
             $outstandingfield = Currency::create();
             $outstandingfield->setValue($order->TotalOutstanding());
             $fields->push(LiteralField::create("Outstanding", sprintf(_t("OrderActionsForm.OUTSTANDING", "Outstanding: %s"), $outstandingfield->Nice())));
             $fields->push(OptionsetField::create('PaymentMethod', _t("OrderActionsForm.PAYMENTMETHOD", "Payment Method"), $gateways, key($gateways)));
             $actions->push(FormAction::create('dopayment', _t('OrderActionsForm.PAYORDER', 'Pay outstanding balance')));
         }
     }
     //cancelling
     if (self::config()->allow_cancelling && $order->canCancel()) {
         $actions->push(FormAction::create('docancel', _t('OrderActionsForm.CANCELORDER', 'Cancel this order')));
     }
     parent::__construct($controller, $name, $fields, $actions);
     $this->extend("updateForm", $order);
 }
 public function __construct($controller, $name = "VariationForm")
 {
     parent::__construct($controller, $name);
     $product = $controller->data();
     $farray = array();
     $requiredfields = array();
     $attributes = $product->VariationAttributeTypes();
     foreach ($attributes as $attribute) {
         $attributeDropdown = $attribute->getDropDownField(_t('VariationForm.ChooseAttribute', "Choose {attribute} …", '', array('attribute' => $attribute->Label)), $product->possibleValuesForAttributeType($attribute));
         if ($attributeDropdown) {
             $farray[] = $attributeDropdown;
             $requiredfields[] = "ProductAttributes[{$attribute->ID}]";
         }
     }
     $fields = FieldList::create($farray);
     if (self::$include_json) {
         $vararray = array();
         $query = $query2 = new SQLQuery();
         $query->setSelect('ID')->setFrom('ProductVariation')->addWhere(array('ProductID' => $product->ID));
         if (!Product::config()->allow_zero_price) {
             $query->addWhere('"Price" > 0');
         }
         foreach ($query->execute()->column('ID') as $variationID) {
             $query2->setSelect('ProductAttributeValueID')->setFrom('ProductVariation_AttributeValues')->setWhere(array('ProductVariationID' => $variationID));
             $vararray[$variationID] = $query2->execute()->keyedColumn();
         }
         $fields->push(HiddenField::create('VariationOptions', 'VariationOptions', json_encode($vararray)));
     }
     $fields->merge($this->Fields());
     $this->setFields($fields);
     $requiredfields[] = 'Quantity';
     $this->setValidator(VariationFormValidator::create($requiredfields));
     $this->extend('updateVariationForm');
 }
 public function FieldHolder($properties = array())
 {
     Requirements::css(LINKABLE_PATH . '/css/embeddedobjectfield.css');
     Requirements::javascript(LINKABLE_PATH . '/javascript/embeddedobjectfield.js');
     if ($this->object && $this->object->ID) {
         $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL'));
         if (strlen($this->object->SourceURL)) {
             $properties['ObjectTitle'] = TextField::create($this->getName() . '[title]', _t('Linkable.TITLE', 'Title'));
             $properties['Width'] = TextField::create($this->getName() . '[width]', _t('Linkable.WIDTH', 'Width'));
             $properties['Height'] = TextField::create($this->getName() . '[height]', _t('Linkable.HEIGHT', 'Height'));
             $properties['ThumbURL'] = HiddenField::create($this->getName() . '[thumburl]', '');
             $properties['Type'] = HiddenField::create($this->getName() . '[type]', '');
             $properties['EmbedHTML'] = HiddenField::create($this->getName() . '[embedhtml]', '');
             $properties['ObjectDescription'] = TextAreaField::create($this->getName() . '[description]', _t('Linkable.DESCRIPTION', 'Description'));
             $properties['ExtraClass'] = TextField::create($this->getName() . '[extraclass]', _t('Linkable.CSSCLASS', 'CSS class'));
             foreach ($properties as $key => $field) {
                 if ($key == 'ObjectTitle') {
                     $key = 'Title';
                 } elseif ($key == 'ObjectDescription') {
                     $key = 'Description';
                 }
                 $field->setValue($this->object->{$key});
             }
             if ($this->object->ThumbURL) {
                 $properties['ThumbImage'] = LiteralField::create($this->getName(), '<img src="' . $this->object->ThumbURL . '" />');
             }
         }
     } else {
         $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL'));
     }
     $field = parent::FieldHolder($properties);
     return $field;
 }
 /**
  * Updates the fields used in the CMS
  * @see DataExtension::updateCMSFields()     
  */
 public function updateCMSFields(FieldList $fields)
 {
     Requirements::CSS('blogcategories/css/cms-blog-categories.css');
     // Try to fetch categories from cache
     $categories = $this->getAllBlogCategories();
     if ($categories->count() >= 1) {
         $cacheKey = md5($categories->sort('LastEdited', 'DESC')->First()->LastEdited);
         $cache = SS_Cache::factory('BlogCategoriesList');
         if (!($categoryList = $cache->load($cacheKey))) {
             $categoryList = "<ul>";
             foreach ($categories->column('Title') as $title) {
                 $categoryList .= "<li>" . Convert::raw2xml($title) . "</li>";
             }
             $categoryList .= "</ul>";
             $cache->save($categoryList, $cacheKey);
         }
     } else {
         $categoryList = "<ul><li>No categories exist. Categories can be added from the BlogTree or the BlogHolder page.</li></ul>";
     }
     //categories tab
     $gridFieldConfig = GridFieldConfig_RelationEditor::create();
     $fields->addFieldToTab('Root.Categories', GridField::create('BlogCategories', 'Blog Categories', $this->owner->BlogCategories(), $gridFieldConfig));
     $fields->addFieldToTab('Root.Categories', ToggleCompositeField::create('ExistingCategories', 'View Existing Categories', array(new LiteralField("CategoryList", $categoryList)))->setHeadingLevel(4));
     // Optionally default category to current holder
     if (Config::inst()->get('BlogCategory', 'limit_to_holder')) {
         $holder = $this->owner->Parent();
         $gridFieldConfig->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function ($form, $component) use($holder) {
             $form->Fields()->push(HiddenField::create('ParentID', false, $holder->ID));
         });
     }
 }
 /**
  * Add the Meta tag CMS fields
  *
  * @since version 1.0.0
  *
  * @return object Return the current page fields
  **/
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Main');
     $fields->addFieldsToTab('Root.SEO', [HeaderField::create('Meta Tag'), DropdownField::create('Type', 'Tag type', $this->tagTypes()), TextField::create('Name'), TextField::create('Value'), HiddenField::create('PageID')]);
     return $fields;
 }
 /**
  * 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;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertBefore(new DropdownField('MemberID', 'Member', Member::get()->map('ID', "FirstName")), 'AttendingWholeEvent');
     $siteConfig = SiteConfig::current_site_config();
     $current = $siteConfig->getCurrentEventID();
     if ($this->ParentID < 1) {
         $event = Event::get()->byID($current);
     } else {
         $event = Event::get()->byID($this->ParentID);
     }
     $fields->insertAfter(HiddenField::create('ParentID', 'Event', $event->ID), 'ExtraDetail');
     $fields->removeByName('PublicFieldsRaw');
     $fields->removeByName('Sort');
     if ($this->PlayerGames()->Count() > 0) {
         $gridField = new GridField('PlayerGames', 'Games', $this->PlayerGames(), $config = GridFieldConfig_RelationEditor::create());
         $gridField->setModelClass('PlayerGame');
         $config->addComponent(new GridFieldOrderableRows());
         $config->removeComponentsByType('GridFieldPaginator');
         $config->removeComponentsByType('GridFieldPageCount');
         $config->addComponent(new GridFieldDeleteAction(false));
         $config->addComponent($export = new GridFieldExportButton('before'));
         $export->setExportColumns(singleton("PlayerGame")->getExportFields());
         $fields->addFieldToTab('Root.PlayerGames', $gridField);
     }
     return $fields;
 }
    public function getCMSFields()
    {
        Requirements::css('widgetify/css/widgetify_cms.css');
        Requirements::javascript('framework/thirdparty/jquery/jquery.js');
        Requirements::javascript('widgetify/scripts/widgetify_page.js');
        $fields = parent::getCMSFields();
        $fields->push(HiddenField::create('WidgetifyContent', 'WidgetifyContent'));
        $fields->push(HiddenField::create('ThisID', 'ThisID', $this->ID));
        $tab = $fields->findOrMakeTab('Root.Main');
        $tab->insertAfter(HeaderField::create('WidgetifyTitle', 'Widgetify Template', 3), 'Metadata');
        if (!$this->WidgetifyTemplateID) {
            $this->WidgetifyTemplateID = 0;
        }
        $templatesMap = DataList::create('WidgetifyTemplate')->map();
        $tab->insertAfter(DropdownField::create('WidgetifyTemplateID', 'Select Template', $templatesMap)->setEmptyString('- Select -'), 'WidgetifyTitle');
        $tab->insertAfter(CheckboxField::create('CSSFrontend', 'Apply template Stylesheet to front-end page'), 'WidgetifyTemplateID');
        $tab->insertAfter(CheckboxField::create('JSFrontend', 'Apply template Javascript to front-end page'), 'CSSFrontend');
        $tab->insertAfter(HeaderField::create('WidgetifyPreviewTitle', 'Widgetify Content', 3), 'JSFrontend');
        $tab->insertAfter(LiteralField::create('WidgetifyPreview', '<div id="widgetifyPreview" class="widgetifyTemplate"></div>'), 'WidgetifyPreviewTitle');
        $htmlField = HtmlEditorField::create('WidgetDynamicContent', false);
        $editorFieldContents = '
			<div id="WidgetDynamicContentHolder" class="WidgetDynamicContentHolder">
				<p id="edit-widget-title">Edit content</p>' . $htmlField->forTemplate() . '
				<p class="widget-edit-actions">
					<a href="javascript:;" id="save-widget-content" class="ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary">Update</a> &nbsp;&nbsp;
					<a href="javascript:;" id="cancel-widget-content" class="ss-ui-action-destructive ui-button ui-widget ui-state-default ui-button-text-icon-primary ui-corner-left ss-ui-button">Cancel</a>
				</p>
			</div>';
        $tab->insertAfter(LiteralField::create('WidgetDynamicContentPlaceHolder', $editorFieldContents), 'WidgetifyPreview');
        $fields->removeFieldFromTab('Root.Main', 'Content');
        return $fields;
    }
 /**
  * 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'));
 }
 /**
  * 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;
 }
 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);
 }
 /**
  * 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;
 }
 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 getHTMLFragments($gridField)
 {
     $model = Injector::inst()->create($gridField->getModelClass());
     $parent = SiteTree::get()->byId(Controller::curr()->currentPageID());
     if (!$model->canCreate()) {
         return array();
     }
     $children = $this->getAllowedChildren($parent);
     if (count($children) > 1) {
         $pageTypes = DropdownField::create("PageType", "Page Type", $children, $model->defaultChild());
         $pageTypes->setFieldHolderTemplate("GridFieldSiteTreeAddNewButton_holder")->addExtraClass("gridfield-dropdown no-change-track");
         if (!$this->buttonName) {
             $this->buttonName = _t('GridFieldSiteTreeAddNewButton.AddMultipleOptions', 'Add new', "Add button text for multiple options.");
         }
     } else {
         $keys = array_keys($children);
         $pageTypes = HiddenField::create('PageType', 'Page Type', $keys[0]);
         if (!$this->buttonName) {
             $this->buttonName = _t('GridFieldSiteTreeAddNewButton.Add', 'Add new {name}', 'Add button text for a single option.', array($children[$keys[0]]));
         }
     }
     $state = $gridField->State->GridFieldSiteTreeAddNewButton;
     $state->currentPageID = $parent->ID;
     $state->pageType = $parent->defaultChild();
     $addAction = new GridField_FormAction($gridField, 'add', $this->buttonName, 'add', 'add');
     $addAction->setAttribute('data-icon', 'add')->addExtraClass("no-ajax ss-ui-action-constructive dropdown-action");
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $forTemplate->Fields->push($pageTypes);
     $forTemplate->Fields->push($addAction);
     Requirements::css(LUMBERJACK_DIR . "/css/lumberjack.css");
     Requirements::javascript(LUMBERJACK_DIR . "/javascript/GridField.js");
     return array($this->targetFragment => $forTemplate->renderWith("GridFieldSiteTreeAddNewButton"));
 }
 public function __construct($controller, $name = "VariationForm")
 {
     parent::__construct($controller, $name);
     $product = $controller->data();
     $farray = array();
     $requiredfields = array();
     $attributes = $product->VariationAttributeTypes();
     foreach ($attributes as $attribute) {
         $farray[] = $attribute->getDropDownField(_t('VariationForm.CHOOSE_ATTRIBUTE', "Choose {attribute} …", '', array('attribute' => $attribute->Label)), $product->possibleValuesForAttributeType($attribute));
         $requiredfields[] = "ProductAttributes[{$attribute->ID}]";
     }
     $fields = FieldList::create($farray);
     if (self::$include_json) {
         $vararray = array();
         if ($vars = $product->Variations()) {
             foreach ($vars as $var) {
                 $vararray[$var->ID] = $var->AttributeValues()->map('ID', 'ID')->toArray();
             }
         }
         $fields->push(HiddenField::create('VariationOptions', 'VariationOptions', json_encode($vararray)));
     }
     $fields->merge($this->Fields());
     $this->setFields($fields);
     $requiredfields[] = 'Quantity';
     $this->setValidator(VariationFormValidator::create($requiredfields));
     $this->extend('updateVariationForm');
 }
 public function __construct($controller, $name, $order)
 {
     /* Store Settings Object */
     $conf = StoreSettings::get_settings();
     /* Comments Box, if enabled */
     if ($conf->CheckoutSettings_OrderComments) {
         $comments = TextareaField::create("CustomerComments", "Order Comments");
         $comments->setRightTitle("These comments will be seen by staff.");
     } else {
         $comments = HiddenField::create("CustomerComments", "");
     }
     /* Terms and Conditions, if enabled */
     if ($conf->CheckoutSettings_TermsAndConditions) {
         $terms = CheckboxField::create("Terms", "I agree to " . $conf->StoreSettings_StoreName . "'s " . "<a href=" . DataObject::get_by_id("SiteTree", $conf->CheckoutSettings_TermsAndConditionsSiteTree)->URLSegment . ">" . "Terms &amp; Conditions</a>.");
     } else {
         $terms = HiddenField::create("Terms", "");
     }
     /* Fields */
     $fields = FieldList::create($comments, OptionsetField::create("PaymentMethod", "Payment Method", Gateway::create()->getGateways($order)), $terms ? HeaderField::create("Terms and Conditions", 5) : HiddenField::create("TermsHeaderField", ""), $terms);
     /* Actions */
     $actions = FieldList::create(FormAction::create('payment', 'Place Order &amp; Continue to Payment'));
     /* Required Fields */
     $required = new RequiredFields(array("PaymentMethod", $terms ? "Terms" : null));
     /*
      * Now we create the actual form with our fields and actions defined 
      * within this class.
      */
     return parent::__construct($controller, $name, $fields, $actions, $required);
 }
 /**
  * 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 updateCMSFields(FieldList $fields)
 {
     if (!$this->owner->hasMethod('getSettingsFields')) {
         $this->updateFields($fields);
     }
     // Instantiate a hidden form field to pass the triggered workflow definition through, allowing a dynamic form action.
     $fields->push(HiddenField::create('TriggeredWorkflowID'));
 }
 /**
  * Factory for generating a change password form. The form can be expanded
  * using an extension class and calling the updateChangePasswordForm method.
  *
  * @return Form
  */
 public function NotificationForm()
 {
     $fields = FieldList::create(HiddenField::create("ID"), CheckboxField::create("RecieveCommentEmails", _t("Discussions.RecieveCommentEmails", "Recieve emails when one of my discussions is replied to")), CheckboxField::create("RecieveNewDiscussionEmails", _t("Discussions.ReveiveNewDiscussionEmails", "Recieve emails when a new discussion is started")), CheckboxField::create("RecieveLikedEmails", _t("Discussions.ReveiveLikedEmails", "Recieve emails when one of my discussions is liked")), CheckboxField::create("RecieveLikedReplyEmails", _t("Discussions.ReveiveLikedReplyEmails", "Recieve emails when a discussion I like is replied to")));
     $actions = FieldList::create(LiteralField::create("CancelLink", '<a href="' . $this->owner->Link() . '" class="btn btn-red">' . _t("Users.CANCEL", "Cancel") . '</a>'), FormAction::create("doSaveNotificationSettings", _t("Discussions.Save", "Save"))->addExtraClass("btn")->addExtraClass("btn-green"));
     $form = Form::create($this->owner, "NotificationForm", $fields, $actions);
     $this->owner->extend("updateNotificationForm", $form);
     return $form;
 }
 public function __construct($name, $title = null, $value = null, $object = null, $form = null)
 {
     $this->object = $object;
     foreach (DBField::config()->composite_db as $point => $type) {
         $this->children[$point] = \HiddenField::create($name . '[' . $point . ']')->addExtraClass('focusarea-point focusarea-point--' . $point)->setForm($form);
     }
     parent::__construct($name, $title, $value, $form);
 }
 public function __construct($controller, $form_name)
 {
     $notify_type = new ListboxField("Type[]", "Select notification type", $source = array("all" => "All post", "newthread" => "New thread"), $value = 'all');
     $fields = new FieldList(CheckboxField::create("Forum[]", 'Forum'), $notify_type, HiddenField::create('MemberID'), HiddenField::create('RedirectURL'));
     //$actions = new FieldList( FormAction::create("doSubmit")->setTitle("Apply"), FormAction::create("doCancel")->setTitle("Go Back"), FormAction::create("doSaveNExit")->setTitle("Save & Exit") );
     $actions = new FieldList(FormAction::create("doSaveNExit")->setTitle("Save & Exit"));
     parent::__construct($controller, $form_name, $fields, $actions);
 }
 /**
  * CMS Fields
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = $this->scaffoldFormFields(array('includeRelations' => $this->ID > 0, 'tabbed' => true, 'ajaxSafe' => true));
     $fields->removeByName('MenuTitle');
     $fields->addFieldsToTab('Root.Main', array(HiddenField::create('UniqueConfigTitle'), TextField::create('AdminTitle', 'Admin title')->setDescription('This field is for adminisration use only and will not display on the site.'), CheckboxField::create('ShowInMenus', 'Show in menus', 0), DisplayLogicWrapper::create(TextField::create('MenuTitle', 'Navigation label'))->displayIf("ShowInMenus")->isChecked()->end()));
     $fields->addFieldsToTab('Root.Settings', array(CheckboxField::create('Public', 'Public', 1)->setDescription('Is this section publicly accessible?.'), DropdownField::create('Style', 'Select a style', $this->ConfigStyles)->setEmptyString('Default')));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Exemple #23
0
 /**
  * @return mixed
  * Calculate power form
  */
 public function CalcForm()
 {
     $fields = new FieldList($addressField = TextField::create('Address', _t('Home.Address', 'Please input your address')), $suburbField = HiddenField::create('Suburb'), $powerField = TextField::create('PowerAmount', _t('Home.PowerAmount', 'Your monthly power consumption')), $withGasField = CheckboxField::create('WithGas', _t('Home.WithGas', 'Also want to check gas plan?')), $gasField = TextField::create('GasAmount', _t('Home.GasAmount', 'Your monthly gas consumption')));
     $gasField->setAttribute('disabled', 'disabled');
     $actions = new FieldList($submitField = FormAction::create('Calculate', _t('Home.Submit', 'Submit')));
     $validator = new RequiredFields('Address', 'PowerAmount');
     $form = Form::create($this, __FUNCTION__, $fields, $actions, $validator);
     return $form;
 }
 /**
  * @return Form
  */
 public function QuickFeedbackForm()
 {
     $fields = FieldList::create(LiteralField::create('RatingTitle', _t('QuickFeedback.Title', '<h4>Was this article helpful?</h4>')), ButtonGroupField::create('Rating', '', array('1' => _t('QuickFeedback.Yes', 'Yes'), '0' => _t('QuickFeedback.No', 'No'))), TextareaField::create('Comment', _t('QuickFeedback.Comment', 'Comment')));
     if ((bool) Config::inst()->get('QuickFeedbackExtension', 'redirect_field')) {
         $fields->push(HiddenField::create('Redirect', null, $_SERVER['REQUEST_URI']));
     }
     $form = Form::create($this->owner, 'QuickFeedbackForm', $fields, FieldList::create(FormAction::create('doSubmit', _t('QuickFeedback.Submit', 'Submit'))));
     return $form;
 }
 /**
  * Updates the CMS Form in the backend, generating an edit form for the movie details.
  *
  * As the Movie-page will solely show the movie details and no further content, the HTML-Content
  * editfield has been removed.
  *
  * This editform uses a new MovieAutoComplete formfield which calls the omdbAPI to retrieve datasets
  * from the web service. @See MovieAutoComplete for more details.
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Add Movie Fields to the Main tab in the edit form (before the content area)
     $fields->addFieldsToTab('Root.Main', array(HeaderField::create('Movies'), MovieAutoComplete::create("SearchTerm", "Search", "", 128)->setAttribute('placeholder', "Please enter a movie name to search for...")->setDescription('After choosing a movie, the details will be used as a template to complete this form.'), HeaderField::create('Movie Details', 'Movie Details', 3), TextField::create('MovieTitle', 'Movie Title', $this->Title), FieldGroup::create(array(TextField::create('Runtime', 'Runtime', $this->Runtime), TextField::create('Rated', 'Rated', $this->Rated)))->setTitle('Details'), FieldGroup::create(array(TextField::create('Country', 'Country', $this->Country), TextField::create('Released', 'Released', $this->Released), TextField::create('Year', 'Year', $this->Year)))->setTitle('Release Info'), TextField::create('Genre', 'Genre', $this->Genre), TextareaField::create('Plot', 'Plot', $this->Plot), HeaderField::create('People Involved', 'People Involved', 3), TextField::create('Director', 'Director', $this->Director), TextField::create('Writer', 'Writer', $this->Writer), TextField::create('Actors', 'Actors', $this->Actors), HeaderField::create('Awards', 'Awards', 3), TextareaField::create('Awards', 'Awards', $this->Awards), HiddenField::create('Type', 'Type', $this->Type), HiddenField::create('ImdbID', 'ImdbID', $this->ImdbID), HiddenField::create('ImdbRating', 'ImdbRating', $this->ImdbRating)), 'Content');
     // Remove the content area (HTMLEditField)
     $fields->removeByName('Content');
     return $fields;
 }
 public function __construct($controller, $name)
 {
     $fields = new FieldList(TextField::create("Name"), EmailField::create("Email")->setAttribute('type', 'email'), TextareaField::create("Company", "Message")->setAttribute('autocomplete', 'no'), TextareaField::create("EmailMessage", "Company")->addExtraClass("honeypot")->setAttribute('autocomplete', 'no'));
     if (!class_exists('FormSpamProtectionExtension')) {
         $fields->insertAfter(HiddenField::create("TimeLog", '', time()), 'EmailMessage');
     }
     $actions = new FieldList(FormAction::create("doSubmit")->setTitle("Submit")->addExtraClass('button')->setUseButtonTag(true));
     parent::__construct($controller, $name, $fields, $actions);
 }
 /**
  * Default Action
  *
  */
 public function index()
 {
     // Setup payment gateway form
     $back_url = Controller::join_links(Director::absoluteBaseURL(), Checkout_Controller::config()->url_segment, "finish");
     $fields = FieldList::create(HiddenField::create('navigate'), HiddenField::create('VPSProtocol', null, $this->payment_gateway->ProtocolVersion), HiddenField::create('TxType', null, 'PAYMENT'), HiddenField::create('Vendor', null, $this->payment_gateway->VendorName), HiddenField::create('Crypt', null, $this->gateway_data()));
     $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($this->payment_gateway->GatewayURL());
     $this->extend('updateForm', $form);
     return array('Title' => _t('Commerce.CheckoutSummary', "Summary"), 'MetaTitle' => _t('Commerce.CheckoutSummary', "Summary"), "Form" => $form);
 }
 /**
  * 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;
 }
 public function __construct($controller, $name, $fields = null, $actions = null)
 {
     $fields = new FieldList(ReadonlyField::create('Title')->setTitle(_t('Box.TITLE', 'Box.TITLE')), TextareaField::create('Description')->setTitle(_t('Box.DESCRIPTION', 'Box.DESCRIPTION')), CheckboxField::create("Public")->setTitle(_t('Box.PUBLIC', 'Box.PUBLIC')), $Members = CheckboxSetField::create('Members')->setTitle(_t('Box.MEMBERS', 'Box.MEMBERS'))->setSource(Member::get()->map('ID', 'Name')), HiddenField::create('BoxID'));
     $actions = new FieldList($Submit = BootstrapLoadingFormAction::create('doEdit')->setTitle(_t('BoxEditForm.DOEDIT', 'BoxEditForm.DOEDIT')));
     parent::__construct($controller, $name, $fields, $actions, new RequiredFields("Description"));
     if (isset($GLOBALS['BoxID'])) {
         $Box = Box::get()->byID($GLOBALS['BoxID']);
         $this->loadDataFrom($Box);
     }
 }
 /**
  * Form used for adding or editing addresses
  */
 public function AddressForm()
 {
     $personal_fields = CompositeField::create(HeaderField::create('PersonalHeader', _t('Checkout.PersonalDetails', 'Personal Details'), 2), TextField::create('FirstName', _t('Checkout.FirstName', 'First Name(s)')), TextField::create('Surname', _t('Checkout.Surname', 'Surname')), CheckboxField::create('Default', _t('Checkout.DefaultAddress', 'Default Address?'))->setRightTitle(_t('Checkout.Optional', 'Optional')))->setName("PersonalFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50');
     $address_fields = CompositeField::create(HeaderField::create('AddressHeader', _t('Checkout.Address', 'Address'), 2), TextField::create('Address1', _t('Checkout.Address1', 'Address Line 1')), TextField::create('Address2', _t('Checkout.Address2', 'Address Line 2'))->setRightTitle(_t('Checkout.Optional', 'Optional')), TextField::create('City', _t('Checkout.City', 'City')), TextField::create('PostCode', _t('Checkout.PostCode', 'Post Code')), CountryDropdownField::create('Country', _t('Checkout.Country', 'Country'))->setAttribute("class", 'countrydropdown dropdown'))->setName("AddressFields")->addExtraClass('unit')->addExtraClass('size1of2')->addExtraClass('unit-50');
     $fields = FieldList::create(HiddenField::create("ID"), HiddenField::create("OwnerID"), CompositeField::create($personal_fields, $address_fields)->setName("DeliveryFields")->addExtraClass('line')->addExtraClass('units-row'));
     $actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $this->owner->Link('addresses') . '" class="btn btn-red">' . _t('Checkout.Cancel', 'Cancel') . '</a>'), FormAction::create('doSaveAddress', _t('Checkout.Add', 'Add'))->addExtraClass('btn')->addExtraClass('btn-green'));
     $validator = RequiredFields::create(array('FirstName', 'Surname', 'Address1', 'City', 'PostCode', 'Country'));
     $form = Form::create($this->owner, "AddressForm", $fields, $actions, $validator);
     return $form;
 }