当前位置: 首页>>代码示例>>PHP>>正文


PHP CompositeField::setID方法代码示例

本文整理汇总了PHP中CompositeField::setID方法的典型用法代码示例。如果您正苦于以下问题:PHP CompositeField::setID方法的具体用法?PHP CompositeField::setID怎么用?PHP CompositeField::setID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CompositeField的用法示例。


在下文中一共展示了CompositeField::setID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCompositeField

 /**
  * @return Comosite FieldSet with Categorys and Items
  */
 function getCompositeField()
 {
     //create new composite field group for each category
     $oCatFieldSet = new CompositeField();
     // Set the field group ID
     $oCatFieldSet->setID('Cat' . $this->ID);
     $oCatFieldSet->addExtraClass('category');
     //create new composite field group for each category
     $oCatField = new TextField($this->ID . '_' . $this->FieldName, $this->Title, null, null);
     $oCatField->addExtraClass('category-field');
     //Add Category Percentage Field to the Form
     $oCatFieldSet->push($oCatField);
     if ($this->Description) {
         $oCatDescField = new LiteralField($this->ID . '_Description', '<p class="category-field-desc">' . $this->Description . '</p>');
         $oCatDescField->addExtraClass('category-field');
         $oCatFieldSet->push($oCatDescField);
     }
     //Add item Composite Field to this Composite Field
     //now get all of the items matched with this category
     $oFormCategoryItems = self::FormCategoryItems();
     foreach ($oFormCategoryItems as $item) {
         $oCatFieldSet->push($item->getFormField());
     }
     return $oCatFieldSet;
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:28,代码来源:FormCategory.php

示例2: CompositeField

    /**                                                              
     * Constructor                                                   
     *                                                               
     * @param  object $controller The controller class                           
     * @param  string $name       The name of the form class              
     * @return object The form                                       
     */
    function __construct($controller, $name)
    {
        //FILTER BLOCK 1 : WHERE ARE YOU
        // Create new group
        $oFilterField1 = new CompositeField();
        // Set the field group ID
        $oFilterField1->setID('Group1');
        // Add fields to the group
        $oFilterField1->push(new LiteralField('Group1Title', '<div class="filter-title-block">Where are you?</div>'));
        $oFilterField1->push(new DropdownField('Country', '', Geoip::getCountryDropDown(), 'NZ'));
        //FILTER BLOCK 2: UPLOAD IMAGE
        // Create new group
        $oFilterField2 = new CompositeField();
        // Set the field group ID
        $oFilterField2->setID('Group2');
        // Add fields to the group
        $oFilterField2->push(new LiteralField('Group2Title', '<div class="filter-title-block">When can you help?</div>'));
        //Set Date Defaults
        $tToday = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
        $dToday = date("d/m/Y", $tToday);
        $tNextMonth = mktime(0, 0, 0, date("m") + 2, date("d"), date("Y"));
        $dNextMonth = date("d/m/Y", $tNextMonth);
        //Check if Dates are Set otherwise use Defaults
        $sFromDate = $this->sFromDate != '' ? $this->sFromDate : $dToday;
        $sToDate = $this->sToDate != '' ? $this->sToDate : $dNextMonth;
        //Date Fields
        $oFromDate = new DatePickerField('FromDate', 'From', $sFromDate);
        $oToDate = new DatePickerField('ToDate', 'To', $sToDate);
        $oFilterField2->push($oFromDate);
        $oFilterField2->push($oToDate);
        DatePickerField::$showclear = false;
        // Create new fieldset
        $oFields = new FieldSet();
        // Add the groups to the fieldset
        $oFields->push($oFilterField1);
        $oFields->push($oFilterField2);
        // Create the form action
        $oAction = new FieldSet(new FormAction('SubmitFilter', 'Find events'));
        // Add custom jQuery validation script for requred fields
        Requirements::customScript('
			
		');
        // Construct the form
        parent::__construct($controller, $name, $oFields, $oAction);
    }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:52,代码来源:EventFilterForm.php

示例3: getEditForm

 /**
  * Return a {@link Form} instance with a
  * a {@link TableListField} for the current
  * {@link LinkCheckRun} record that we're currently
  * looking it, the ID for that LinkCheckRun record
  * is accessible from the URL as the "ID" parameter.
  * 
  * @uses LinkCheckAdmin->getLinkCheckRun()
  * @todo Fix up the hardcoded english strings
  * @todo Split functionality to separate methods
  * 
  * @return Form
  */
 public function getEditForm($id = null)
 {
     $run = $this->getLinkCheckRun($id);
     if (!$run) {
         return false;
     }
     $runCMSFields = $run->getCMSFields();
     $runCompFields = new CompositeField();
     $runCompFields->setID('RunFields');
     if ($runCMSFields) {
         foreach ($runCMSFields as $runCMSField) {
             $runCompFields->push($runCMSField);
         }
     }
     $brokenLinkCount = $run->BrokenLinks() ? $run->BrokenLinks()->Count() : 0;
     $finishedDate = $run->obj('FinishDate')->Nice();
     $pagesChecked = $run->PagesChecked;
     if ($run->IsComplete) {
         // Run is complete
         if ($brokenLinkCount == 1) {
             $resultNumField = new LiteralField('ResultNo', "<p>Finished at {$finishedDate}. {$pagesChecked} pages were checked. 1 broken link was found.</p>");
         } elseif ($brokenLinkCount > 0) {
             $resultNumField = new LiteralField('ResultNo', "<p>Finished at {$finishedDate}. {$pagesChecked} pages were checked. {$brokenLinkCount} broken links were found.</p>");
         } else {
             $resultNumField = new LiteralField('ResultNo', "<p>Finished at {$finishedDate}. {$pagesChecked} pages were checked. No broken links were found.</p>");
         }
     } else {
         // Run not completed yet
         if ($brokenLinkCount == 1) {
             $resultNumField = new LiteralField('ResultNo', '<p>This link check run is not completed yet. 1 broken link found so far.</p>');
         } elseif ($brokenLinkCount > 0) {
             $resultNumField = new LiteralField('ResultNo', "<p>This link check run is not completed yet. {$brokenLinkCount} broken links found so far.</p>");
         } else {
             $resultNumField = new LiteralField('ResultNo', '<p>This link check run is not completed yet. No broken links found so far.</p>');
         }
     }
     $runDate = $run->obj('Created')->Nice();
     $fields = new FieldSet(new TabSet('Root', new Tab(_t('LinkCheckAdmin.CHECKRUN', 'Results'), new HeaderField('Link check run', 2), new LiteralField('ResultText', "<p>Run at {$runDate}</p>"), $resultNumField, $runCompFields)));
     $fields->push(new HiddenField('LinkCheckRunID', '', $run->ID));
     $fields->push(new HiddenField('ID', '', $run->ID));
     $actions = new FieldSet(new FormAction('save', 'Save'));
     $form = new Form($this, 'EditForm', $fields, $actions);
     $form->loadDataFrom($run);
     return $form;
 }
开发者ID:halkyon,项目名称:silverstripe-linkchecker,代码行数:58,代码来源:LinkCheckAdmin.php

示例4: array

 function __construct($controller, $name)
 {
     //requirements
     Requirements::javascript('ecommerce/javascript/EcomOrderForm.js');
     //set basics
     $order = ShoppingCart::current_order();
     $order->calculateOrderAttributes($force = true);
     $requiredFields = array();
     //  ________________  3) Payment fields - BOTTOM FIELDS
     $bottomFields = new CompositeField();
     $bottomFields->setID('BottomOrder');
     $totalAsCurrencyObject = $order->TotalAsCurrencyObject();
     //should instead be $totalobj = $order->dbObject('Total');
     $totalOutstandingAsMoneyObject = $order->TotalAsMoneyObject();
     $paymentFields = Payment::combined_form_fields($totalOutstandingAsMoneyObject->Nice());
     foreach ($paymentFields as $paymentField) {
         if ($paymentField->class == "HeaderField") {
             $paymentField->setTitle(_t("OrderForm.MAKEPAYMENT", "Choose Payment"));
         }
         $bottomFields->push($paymentField);
     }
     if ($paymentRequiredFields = Payment::combined_form_requirements()) {
         $requiredFields = array_merge($requiredFields, $paymentRequiredFields);
     }
     //  ________________  4) FINAL FIELDS
     $finalFields = new CompositeField();
     $finalFields->setID('FinalFields');
     $finalFields->push(new HeaderField('CompleteOrder', _t('OrderForm.COMPLETEORDER', 'Complete Order'), 3));
     // If a terms and conditions page exists, we need to create a field to confirm the user has read it
     if ($termsAndConditionsPage = CheckoutPage::find_terms_and_conditions_page()) {
         $checkoutPage = DataObject::get_one("CheckoutPage");
         if ($checkoutPage && $checkoutPage->TermsAndConditionsMessage) {
             $alreadyTicked = false;
             $requiredFields[] = 'ReadTermsAndConditions';
         } else {
             $alreadyTicked = true;
         }
         $finalFields->push(new CheckboxField('ReadTermsAndConditions', _t('OrderForm.AGREEWITHTERMS1', 'I have read and agree with the ') . ' <a href="' . $termsAndConditionsPage->Link() . '">' . Convert::raw2xml($termsAndConditionsPage->Title) . '</a>' . _t('OrderForm.AGREEWITHTERMS2', '.'), $alreadyTicked));
     }
     $finalFields->push(new TextareaField('CustomerOrderNote', _t('OrderForm.CUSTOMERNOTE', 'Note / Question'), 7, 30));
     //  ________________  5) Put all the fields in one FieldSet
     $fields = new FieldSet($bottomFields, $finalFields);
     //  ________________  6) Actions and required fields creation + Final Form construction
     $actions = new FieldSet(new FormAction('processOrder', _t('OrderForm.PROCESSORDER', 'Place order and make payment')));
     $validator = new OrderForm_Validator($requiredFields);
     //we stick with standard validation here, because of the complexity and
     //hard-coded payment validation that is required
     $validator->setJavascriptValidationHandler("prototype");
     parent::__construct($controller, $name, $fields, $actions, $validator);
     //extensions need to be set after __construct
     if ($this->extend('updateFields', $fields) !== null) {
         $this->setFields($fields);
     }
     if ($this->extend('updateActions', $actions) !== null) {
         $this->setActions($actions);
     }
     if ($this->extend('updateValidator', $validator) !== null) {
         $this->setValidator($validator);
     }
     //  ________________  7)  Load saved data
     if ($order) {
         $this->loadDataFrom($order);
     }
     //allow updating via decoration
     $this->extend('updateOrderForm', $this);
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:66,代码来源:OrderForm.php

示例5: getForumFields

 /**
  * Get the fields needed by the forum module
  *
  * @param bool $showIdentityURL Should a field for an OpenID or an i-name
  *                              be shown (always read-only)?
  * @return FieldSet Returns a FieldSet containing all needed fields for
  *                  the registration of new users
  */
 function getForumFields($showIdentityURL = false, $addmode = false)
 {
     $gravatarText = DataObject::get_one("ForumHolder", "\"AllowGravatars\" = 1") ? '<small>' . _t('ForumRole.CANGRAVATAR', 'If you use Gravatars then leave this blank') . '</small>' : "";
     $personalDetailsFields = new CompositeField(new HeaderField("PersonalDetails", _t('ForumRole.PERSONAL', 'Personal Details')), new LiteralField("Blurb", "<p id=\"helpful\">" . _t('ForumRole.TICK', 'Tick the fields to show in public profile') . "</p>"), new TextField("Nickname", _t('ForumRole.NICKNAME', 'Nickname')), new CheckableOption("FirstNamePublic", new TextField("FirstName", _t('ForumRole.FIRSTNAME', 'First name'))), new CheckableOption("SurnamePublic", new TextField("Surname", _t('ForumRole.SURNAME', 'Surname'))), new CheckableOption("OccupationPublic", new TextField("Occupation", _t('ForumRole.OCCUPATION', 'Occupation')), true), new CheckableOption('CompanyPublic', new TextField('Company', _t('ForumRole.COMPANY', 'Company')), true), new CheckableOption('CityPublic', new TextField('City', _t('ForumRole.CITY', 'City')), true), new CheckableOption("CountryPublic", new CountryDropdownField("Country", _t('ForumRole.COUNTRY', 'Country')), true), new CheckableOption("EmailPublic", new EmailField("Email", _t('ForumRole.EMAIL', 'Email'))), new ConfirmedPasswordField("Password", _t('ForumRole.PASSWORD', 'Password')), new SimpleImageField("Avatar", _t('ForumRole.AVATAR', 'Upload avatar ') . ' ' . $gravatarText), new ReadonlyField("ForumRank", _t('ForumRole.RATING', 'User rating')));
     $personalDetailsFields->setID('PersonalDetailsFields');
     $fieldset = new FieldSet($personalDetailsFields);
     if ($showIdentityURL) {
         $fieldset->insertBefore(new ReadonlyField('IdentityURL', _t('ForumRole.OPENIDINAME', 'OpenID/i-name')), 'Password');
         $fieldset->insertAfter(new LiteralField('PasswordOptionalMessage', '<p>' . _t('ForumRole.PASSOPTMESSAGE', 'Since you provided an OpenID respectively an i-name the password is optional. If you enter one, you will be able to log in also with your e-mail address.') . '</p>'), 'IdentityURL');
     }
     $this->owner->extend('updateForumFields', $fieldset);
     return $fieldset;
 }
开发者ID:RyeDesigns,项目名称:silverstripe-forum,代码行数:21,代码来源:ForumRole.php

示例6: addPaymentFields

 /**
  * Add pament fields for the current payment method. Also adds payment method as a required field.
  * 
  * @param Array $fields Array of fields
  * @param OrderFormValidator $validator Checkout form validator
  * @param Order $order The current order
  */
 private function addPaymentFields(&$fields, &$validator, $order)
 {
     $paymentFields = new CompositeField();
     foreach (Payment::combined_form_fields($order->Total->getAmount()) as $field) {
         //Bit of a nasty hack to customize validation error message
         if ($field->Name() == 'PaymentMethod') {
             $field->setCustomValidationMessage(_t('CheckoutPage.SELECT_PAYMENT_METHOD', "Please select a payment method."));
         }
         $paymentFields->push($field);
     }
     $paymentFields->setID('PaymentFields');
     $fields['Payment'][] = $paymentFields;
     //TODO need to check required payment fields
     //$requiredPaymentFields = Payment::combined_form_requirements();
     $validator->addRequiredField('PaymentMethod');
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe,代码行数:23,代码来源:CheckoutPage.php

示例7: FieldSet

 /**
  * Return a set of payment fields from all enabled
  * payment methods for this site, given the . {@link Payment::set_supported_methods()}
  * is used to define which methods are available.
  *
  * @return FieldSet
  */
 static function combined_form_fields($amount)
 {
     // Create the initial form fields, which defines an OptionsetField
     // allowing the user to choose which payment method to use.
     $fields = new FieldSet(new HeaderField(_t('Payment.PAYMENTTYPE', 'Payment Type'), 3), new OptionsetField('PaymentMethod', '', self::$supported_methods, array_shift(array_keys(self::$supported_methods))));
     // If the user defined an numerically indexed array, throw an error
     if (ArrayLib::is_associative(self::$supported_methods)) {
         foreach (self::$supported_methods as $methodClass => $methodTitle) {
             // Create a new CompositeField with method specific fields,
             // as defined on each payment method class using getPaymentFormFields()
             $methodFields = new CompositeField(singleton($methodClass)->getPaymentFormFields());
             $methodFields->setID("MethodFields_{$methodClass}");
             $methodFields->addExtraClass('paymentfields');
             // Add those fields to the initial FieldSet we first created
             $fields->push($methodFields);
         }
     } else {
         user_error('Payment::set_supported_methods() requires an associative array.', E_USER_ERROR);
     }
     // Add the amount and subtotal fields for the payment amount
     $fields->push(new ReadonlyField('Amount', _t('Payment.AMOUNT', 'Amount'), $amount));
     return $fields;
 }
开发者ID:nimeso,项目名称:silverstripe-payment,代码行数:30,代码来源:Payment.php

示例8: Form

    public function Form()
    {
        if ($this->URLParams['Action'] === 'completed' || $this->URLParams['Action'] == 'submitted') {
            return;
        }
        $dataFields = singleton('Recipient')->getFrontEndFields()->dataFields();
        if ($this->CustomLabel) {
            $customLabel = Convert::json2array($this->CustomLabel);
        }
        $fields = array();
        if ($this->Fields) {
            $fields = explode(",", $this->Fields);
        }
        $recipientInfoSection = new CompositeField();
        $requiredFields = Convert::json2array($this->Required);
        if (!empty($fields)) {
            foreach ($fields as $field) {
                if (isset($dataFields[$field]) && $dataFields[$field]) {
                    if (is_a($dataFields[$field], "ImageField")) {
                        if (isset($requiredFields[$field])) {
                            $title = $dataFields[$field]->Title() . " * ";
                        } else {
                            $title = $dataFields[$field]->Title();
                        }
                        $dataFields[$field] = new SimpleImageField($dataFields[$field]->Name(), $title);
                    } else {
                        if (isset($requiredFields[$field])) {
                            if (isset($customLabel[$field])) {
                                $title = $customLabel[$field] . " * ";
                            } else {
                                $title = $dataFields[$field]->Title() . " * ";
                            }
                        } else {
                            if (isset($customLabel[$field])) {
                                $title = $customLabel[$field];
                            } else {
                                $title = $dataFields[$field]->Title();
                            }
                        }
                        $dataFields[$field]->setTitle($title);
                    }
                    $recipientInfoSection->push($dataFields[$field]);
                }
            }
        }
        $formFields = new FieldList(new HeaderField("CustomisedHeading", $this->owner->CustomisedHeading), $recipientInfoSection);
        $recipientInfoSection->setID("MemberInfoSection");
        if ($this->MailingLists) {
            $mailinglists = DataObject::get("MailingList", "ID IN (" . $this->MailingLists . ")");
        }
        if (isset($mailinglists) && $mailinglists && $mailinglists->count() > 1) {
            $newsletterSection = new CompositeField(new LabelField("Newsletters", _t("SubscriptionPage.To", "Subscribe to:"), 4), new CheckboxSetField("NewsletterSelection", "", $mailinglists, $mailinglists->getIDList()));
            $formFields->push($newsletterSection);
        }
        $buttonTitle = $this->SubmissionButtonText;
        $actions = new FieldList(new FormAction('doSubscribe', $buttonTitle));
        if (!empty($requiredFields)) {
            $required = new RequiredFields($requiredFields);
        } else {
            $required = null;
        }
        $form = new Form($this, "Form", $formFields, $actions, $required);
        // using jQuery to customise the validation of the form
        $FormName = $form->FormName();
        $validationMessage = Convert::json2array($this->ValidationMessage);
        if (!empty($requiredFields)) {
            $jsonRuleArray = array();
            $jsonMessageArray = array();
            foreach ($requiredFields as $field => $true) {
                if ($true) {
                    if (isset($validationMessage[$field]) && $validationMessage[$field]) {
                        $error = $validationMessage[$field];
                    } else {
                        $label = isset($customLabel[$field]) ? $customLabel[$field] : $dataFields[$field]->Title();
                        $error = sprintf(_t('Newsletter.PleaseEnter', "Please enter your %s field"), $label);
                    }
                    if ($field === 'Email') {
                        $jsonRuleArray[] = $field . ":{required: true, email: true}";
                        $message = <<<JSON
{
required: "<span class='exclamation'></span><span class='validation-bubble'>
{$error}<span></span></span>",
email: "<span class='exclamation'></span><span class='validation-bubble'>
Please enter a valid email address<span></span></span>"
}
JSON;
                        $jsonMessageArray[] = $field . ":{$message}";
                    } else {
                        $jsonRuleArray[] = $field . ":{required: true}";
                        $message = <<<HTML
<span class='exclamation'></span><span class='validation-bubble'>{$error}<span></span></span>
HTML;
                        $jsonMessageArray[] = $field . ":\"{$message}\"";
                    }
                }
            }
            $rules = "{" . implode(", ", $jsonRuleArray) . "}";
            $messages = "{" . implode(",", $jsonMessageArray) . "}";
        } else {
            $rules = "{Email:{required: true, email: true}}";
//.........这里部分代码省略.........
开发者ID:Zauberfisch,项目名称:silverstripe-newsletter,代码行数:101,代码来源:SubscriptionPage.php

示例9: Form

    function Form()
    {
        if ($this->URLParams['Action'] == 'complete') {
            return;
        }
        $dataFields = singleton('Member')->getCMSFields()->dataFields();
        if ($this->CustomisedLables) {
            $customisedLables = Convert::json2array($this->CustomisedLables);
        }
        $fields = array();
        if ($this->Fields) {
            $fields = explode(",", $this->Fields);
        }
        $memberInfoSection = new CompositeField();
        if (!empty($fields)) {
            foreach ($fields as $field) {
                if (isset($dataFields[$field]) && $dataFields[$field]) {
                    if (isset($customisedLables[$field])) {
                        $dataFields[$field]->setTitle($customisedLables[$field]);
                    }
                    if (is_a($dataFields[$field], "ImageField")) {
                        $dataFields[$field] = new SimpleImageField($dataFields[$field]->Name(), $dataFields[$field]->Title());
                    }
                    $memberInfoSection->push($dataFields[$field]);
                }
            }
        }
        $formFields = new FieldSet(new HeaderField("MemberInfo", _t("SubscriptionPage.Information", "Member Infomation:"), 2), $memberInfoSection);
        $memberInfoSection->setID("MemberInfoSection");
        if ($this->NewsletterTypes) {
            $newsletters = DataObject::get("NewsletterType", "ID IN (" . $this->NewsletterTypes . ")");
        }
        if (isset($newsletters) && $newsletters && $newsletters->count() > 1) {
            $newsletterSection = new CompositeField(new LabelField("Newsletters", _t("SubscriptionPage.To", "Subscribe to:"), 4), new CheckboxSetField("NewsletterSelection", "", $newsletters));
            $formFields->push($newsletterSection);
        }
        $buttonTitle = $this->SubmissionButtonText;
        $actions = new FieldSet(new FormAction('doSubscribe', $buttonTitle));
        $form = new Form($this, "Form", $formFields, $actions);
        // using jQuery to customise the validation of the form
        $FormName = $form->FormName();
        $messages = $this->CustomisedErrors;
        if ($this->Required) {
            $jsonRuleArray = array();
            foreach (Convert::json2array($this->Required) as $field => $true) {
                if ($true) {
                    if ($field === 'Email') {
                        $jsonRuleArray[] = $field . ":{required: true, email: true}";
                    } else {
                        $jsonRuleArray[] = $field . ":{required: true}";
                    }
                }
            }
            $rules = "{" . implode(", ", $jsonRuleArray) . "}";
        } else {
            $rules = "{Email:{required: true, email: true}}";
        }
        // set the custom script for this form
        Requirements::customScript(<<<JS
\t\t\t(function(\$) {
\t\t\t\tjQuery(document).ready(function() {
\t\t\t\t\tjQuery("#{$FormName}").validate({
\t\t\t\t\t\terrorClass: "required",
\t\t\t\t\t\tfocusCleanup: true,
\t\t\t\t\t\tmessages: {$messages},
\t\t\t\t\t\trules: {$rules}
\t\t\t\t\t});
\t\t\t\t});
\t\t\t})(jQuery);
JS
);
        return $form;
    }
开发者ID:roed,项目名称:silverstripe-newsletter,代码行数:73,代码来源:SubscriptionPage.php

示例10: CorporateAddressFieldsArray

 /**
  * returns an array of fields for the corporate account
  * @return Array
  */
 public function CorporateAddressFieldsArray($forCMS = false)
 {
     $fields = array();
     if ($this->owner->Title != $this->owner->CombinedCorporateGroupName()) {
         $fields[] = new ReadOnlyField("CombinedCorporateGroupName", _t("EcommerceCorporateGroup.FULLNAME", "Full Name"), $this->owner->CombinedCorporateGroupName());
     }
     foreach (self::$address_types as $fieldGroupPrefix => $fieldGroupTitle) {
         if ($forCMS) {
             $fields[] = new HeaderField($fieldGroupPrefix . "Header", $fieldGroupTitle, 4);
         } else {
             $composite = new CompositeField();
             $composite->setID($fieldGroupPrefix);
             $composite->push(new HeaderField($fieldGroupPrefix . "Header", $fieldGroupTitle, 4));
         }
         foreach (self::$address_fields as $name => $field) {
             $fieldClass = 'TextField';
             if ($field == 'Text') {
                 $fieldClass = 'TextareaField';
             } elseif ($name == 'Country') {
                 $fieldClass = 'CountryDropdownField';
             }
             if ($forCMS) {
                 $fields[] = new $fieldClass($fieldGroupPrefix . $name, $name);
             } else {
                 $composite->push(new $fieldClass($fieldGroupPrefix . $name, $name));
             }
         }
         if ($forCMS) {
             //
         } else {
             $fields[] = $composite;
         }
     }
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-corporate-account,代码行数:39,代码来源:EcommerceCorporateGroupGroupDecorator.php

示例11: singleton

 function __construct($controller, $name)
 {
     Requirements::themedCSS('OrderForm');
     // 1) Member and shipping fields
     $member = Member::currentUser() ? Member::currentUser() : singleton('Member');
     $memberFields = new CompositeField($member->getEcommerceFields());
     $requiredFields = $member->getEcommerceRequiredFields();
     if (ShoppingCart::uses_different_shipping_address()) {
         $countryField = new DropdownField('ShippingCountry', 'Country', Geoip::getCountryDropDown(), EcommerceRole::findCountry());
         $shippingFields = new CompositeField(new HeaderField('Send goods to different address', 3), new LiteralField('ShippingNote', '<p class="warningMessage"><em>Your goods will be sent to the address below.</em></p>'), new LiteralField('Help', '<p>You can use this for gift giving. No billing information will be disclosed to this address.</p>'), new TextField('ShippingName', 'Name'), new TextField('ShippingAddress', 'Address'), new TextField('ShippingAddress2', ''), new TextField('ShippingCity', 'City'), $countryField, new HiddenField('UseShippingAddress', '', true), new FormAction_WithoutLabel('useMemberShippingAddress', 'Use Billing Address for Shipping'));
         $requiredFields[] = 'ShippingName';
         $requiredFields[] = 'ShippingAddress';
         $requiredFields[] = 'ShippingCity';
         $requiredFields[] = 'ShippingCountry';
     } else {
         $countryField = $memberFields->fieldByName('Country');
         $shippingFields = new FormAction_WithoutLabel('useDifferentShippingAddress', 'Use Different Shipping Address');
     }
     $countryField->addExtraClass('ajaxCountryField');
     $setCountryLinkID = $countryField->id() . '_SetCountryLink';
     $setContryLink = ShoppingCart_Controller::set_country_link();
     $memberFields->push(new HiddenField($setCountryLinkID, '', $setContryLink));
     $leftFields = new CompositeField($memberFields, $shippingFields);
     $leftFields->setID('LeftOrder');
     $rightFields = new CompositeField();
     $rightFields->setID('RightOrder');
     if (!$member->ID || $member->Password == '') {
         $rightFields->push(new HeaderField('Membership Details', 3));
         $rightFields->push(new LiteralField('MemberInfo', "<p class=\"message good\">If you are already a member, please <a href=\"Security/login?BackURL=" . CheckoutPage::find_link(true) . "/\">log in</a>.</p>"));
         $rightFields->push(new LiteralField('AccountInfo', "<p>Please choose a password, so you can login and check your order history in the future.</p><br/>"));
         $rightFields->push(new FieldGroup(new ConfirmedPasswordField('Password', 'Password')));
         $requiredFields[] = 'Password[_Password]';
         $requiredFields[] = 'Password[_ConfirmPassword]';
     }
     // 2) Payment fields
     $currentOrder = ShoppingCart::current_order();
     $total = '$' . number_format($currentOrder->Total(), 2);
     $paymentFields = Payment::combined_form_fields("{$total} " . $currentOrder->Currency(), $currentOrder->Total());
     foreach ($paymentFields as $field) {
         $rightFields->push($field);
     }
     if ($paymentRequiredFields = Payment::combined_form_requirements()) {
         $requiredFields = array_merge($requiredFields, $paymentRequiredFields);
     }
     // 3) Put all the fields in one FieldSet
     $fields = new FieldSet($leftFields, $rightFields);
     // 4) Terms and conditions field
     // If a terms and conditions page exists, we need to create a field to confirm the user has read it
     if ($controller->TermsPageID && ($termsPage = DataObject::get_by_id('Page', $controller->TermsPageID))) {
         $bottomFields = new CompositeField(new CheckboxField('ReadTermsAndConditions', "I agree to the terms and conditions stated on the <a href=\"{$termsPage->URLSegment}\" title=\"Read the shop terms and conditions for this site\">terms and conditions</a> page"));
         $bottomFields->setID('BottomOrder');
         $fields->push($bottomFields);
         $requiredFields[] = 'ReadTermsAndConditions';
     }
     // 5) Actions and required fields creation
     $actions = new FieldSet(new FormAction('processOrder', 'Place order and make payment'));
     $requiredFields = new CustomRequiredFields($requiredFields);
     // 6) Form construction
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     // 7) Member details loading
     if ($member->ID) {
         $this->loadDataFrom($member);
     }
     // 8) Country field value update
     $currentOrder = ShoppingCart::current_order();
     $currentOrderCountry = $currentOrder->findShippingCountry(true);
     $countryField->setValue($currentOrderCountry);
 }
开发者ID:nicolaas,项目名称:silverstripe-ecommerce,代码行数:68,代码来源:OrderForm.php

示例12: getForumFields

 /**
  * Get the fields needed by the forum module
  *
  * @param bool $showIdentityURL Should a field for an OpenID or an i-name
  *                              be shown (always read-only)?
  * @return FieldList Returns a FieldList containing all needed fields for
  *                  the registration of new users
  */
 function getForumFields($showIdentityURL = false, $addmode = false)
 {
     $gravatarText = DataObject::get_one("ForumHolder", "\"AllowGravatars\" = 1") ? '<small>' . _t('ForumRole.CANGRAVATAR', 'If you use Gravatars then leave this blank') . '</small>' : "";
     //Sets the upload folder to the Configurable one set via the ForumHolder or overridden via Config::inst()->update().
     $avatarField = new FileField('Avatar', _t('ForumRole.AVATAR', 'Avatar Image') . ' ' . $gravatarText);
     $avatarField->setFolderName(Config::inst()->get('ForumHolder', 'avatars_folder'));
     $avatarField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
     $personalDetailsFields = new CompositeField(new HeaderField("PersonalDetails", _t('ForumRole.PERSONAL', 'Personal Details')), new LiteralField("Blurb", "<p id=\"helpful\">" . _t('ForumRole.TICK', 'Tick the fields to show in public profile') . "</p>"), new TextField("Nickname", _t('ForumRole.NICKNAME', 'Nickname')), new CheckableOption("FirstNamePublic", new TextField("FirstName", _t('ForumRole.FIRSTNAME', 'First name'))), new CheckableOption("SurnamePublic", new TextField("Surname", _t('ForumRole.SURNAME', 'Surname'))), new CheckableOption("OccupationPublic", new TextField("Occupation", _t('ForumRole.OCCUPATION', 'Occupation')), true), new CheckableOption('CompanyPublic', new TextField('Company', _t('ForumRole.COMPANY', 'Company')), true), new CheckableOption('CityPublic', new TextField('City', _t('ForumRole.CITY', 'City')), true), new CheckableOption("CountryPublic", new ForumCountryDropdownField("Country", _t('ForumRole.COUNTRY', 'Country')), true), new CheckableOption("EmailPublic", new EmailField("Email", _t('ForumRole.EMAIL', 'Email'))), new ConfirmedPasswordField("Password", _t('ForumRole.PASSWORD', 'Password')), $avatarField);
     // Don't show 'forum rank' at registration
     if (!$addmode) {
         $personalDetailsFields->push(new ReadonlyField("ForumRank", _t('ForumRole.RATING', 'User rating')));
     }
     $personalDetailsFields->setID('PersonalDetailsFields');
     $fieldset = new FieldList($personalDetailsFields);
     if ($showIdentityURL) {
         $fieldset->insertBefore(new ReadonlyField('IdentityURL', _t('ForumRole.OPENIDINAME', 'OpenID/i-name')), 'Password');
         $fieldset->insertAfter(new LiteralField('PasswordOptionalMessage', '<p>' . _t('ForumRole.PASSOPTMESSAGE', 'Since you provided an OpenID respectively an i-name the password is optional. If you enter one, you will be able to log in also with your e-mail address.') . '</p>'), 'IdentityURL');
     }
     if ($this->owner->IsSuspended()) {
         $fieldset->insertAfter(new LiteralField('SuspensionNote', '<p class="message warning suspensionWarning">' . $this->ForumSuspensionMessage() . '</p>'), 'Blurb');
     }
     $this->owner->extend('updateForumFields', $fieldset);
     return $fieldset;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-forum,代码行数:32,代码来源:ForumRole.php

示例13: CompositeField

    /**                                                              
     * Constructor                                                   
     *                                                               
     * @param  object $controller The controller class                           
     * @param  string $name       The name of the form class              
     * @return object The form                                       
     */
    function __construct($controller, $name)
    {
        //DATA STEP 1 : BASIC INFO
        // Create new group
        $oDataField1 = new CompositeField();
        // Set the field group ID
        $oDataField1->setID('Group1');
        // Add fields to the group
        $oDataField1->push(new LiteralField('Group1Title', '<div class="data-title-block"><img src="themes/lyc2012/img/s1.jpg" />
		<h2>Overview</h2><span>Basic event results. If you do not know the exact numbers, simply make an estimate.</span></div>'));
        $oDataField1->push(new DropdownField('CleanUpGroupID', 'Select an Event to add data for', self::mapCleanUps()));
        $oDataField1->push(new TextField('Participants', 'Number of participants'));
        $oDataField1->push(new LiteralField('Help1', '<p class="category-field-desc">How many people turned-up to help? Your number will be added to the tally at the top of this page.</p>'));
        $oDataField1->push(new TextField('Sacks', 'Sacks of rubbish'));
        $oDataField1->push(new LiteralField('Help2', '<p class="category-field-desc">How many full rubbish sacks did you collect? Your number will be added to the tally at the top of this page.</p>'));
        $oDataField1->push(new TextField('Distance', 'Distance covered'));
        $oDataField1->push(new LiteralField('Help3', '<p class="category-field-desc">How far did participants walk while cleaning-up? This provides an idea of the state of your coastlines.</p>'));
        $oDataField1->push(new TextField('Time', 'Time spent'));
        $oDataField1->push(new LiteralField('Help3', '<p class="category-field-desc">How long did participants spend cleaning-up? This provides an idea of the effort involved.</p>'));
        $oDataField1->push(new LiteralField('Group1Anchor', '
		<div class="Actions margin-top">
			<p class="continue">Got a photo or rubbish data? If yes, continue below. Otherwise</p><a class="orange action" href="#end">Finish now</a>
		</div>'));
        //DATA STEP 2 : UPLOAD IMAGE
        // Create new group
        $oDataField2 = new CompositeField();
        // Set the field group ID
        $oDataField2->setID('Group2');
        //Set-up uploadify Field
        $oDataField2->push(new LiteralField('Group2Title', '<div class="data-title-block"><img src="themes/lyc2012/img/s2.jpg" />
		<h2>Photo</h2><span>(optional) If you do not have any photos from your event, skip this step. </span></div>'));
        $oDataField2->push(new SimpleImageField('DataImageFile', 'Upload event photo'));
        $oDataField2->push(new LiteralField('Help3', '<p class="category-field-desc">Any event photo, but the preference is for a photo of the rubbish collected or of your event participants. Max file size 100KB.</p>'));
        $oDataField2->push(new LiteralField('Group1Anchor', '
		<div class="Actions margin-top">
			<p class="continue">Got rubbish data? If yes, continue below. Otherwise</p><a class="orange action" href="#end">Finish now</a>
		</div>'));
        //DATA STEP 3 : DATA FIELDS
        // Create new group
        $oFieldsCat = new CompositeField();
        $oFieldsCat->setID('Group3');
        $oFieldsCat->push(new LiteralField('Group3Title', '<div class="data-title-block"><img src="themes/lyc2012/img/s3.jpg" />
		<h2>Results</h2><span>(optional) Complete this section if you have estimated or counted the types of rubbish collected.</span></div>'));
        $oFieldsCat->push(new LiteralField('Group3Title2', '<div class="data-title-block"><img src="themes/lyc2012/img/either.png" />
		<h2>Upload</h2><span>Choose this option if you have filled-in your data electronically on our Event Results Spreadsheet.</span></div>'));
        $oFieldsCat->push(new FileField('DataSheetFile', 'Upload a spreadsheet containing your data'));
        //$oFieldsCat->push(new LiteralField('Help3', '<p class="category-field-desc">Choose this option if you have filled-in your data electronically on our Event Results Spreadsheet.</p>'));
        $oFieldsCat->push(new LiteralField('Group1Anchor', '
		<div class="Actions margin-top">
			<p class="continue">Skip this step and enter data below. Otherwise</p><a class="action orange" href="#end">Finish now</a>
		</div>'));
        $oFieldsCat->push(new LiteralField('Group3Title2', '<div class="data-title-block"><img src="themes/lyc2012/img/OR.png" />
		<h2>Enter</h2><span>Choose this option if you have recorded data but do not have it in our spreadsheet (e.g. you recorded it on paper).</span></div>'));
        //Get all FormCategorys
        $oFormCategorys = DataObject::get('FormCategory');
        if ($oFormCategorys) {
            foreach ($oFormCategorys as $category) {
                $oFieldsCat->push($category->getCompositeField());
            }
        }
        $oFieldsCat->push(new LiteralField('Group4Anchor', '
		<a name="end">&nbsp;</a>
		'));
        // Create new fieldset
        $oFields = new FieldSet();
        // Add the groups to the fieldset
        $oFields->push($oDataField1);
        $oFields->push($oDataField2);
        $oFields->push($oFieldsCat);
        //$oFields->push($oDataField4);
        // Create the form action
        $oAction = new FieldSet(new FormAction('SubmitDataSheet', 'Share Results'));
        // Add custom jQuery validation script for requred fields
        Requirements::javascript("mysite/javascript/DataFormVal.js");
        // Construct the form
        parent::__construct($controller, $name, $oFields, $oAction);
    }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:84,代码来源:DataEntryForm.php

示例14: CompositeField

    function __construct($controller, $name, $TermsAndConditions, $TermsAndConditionsFileURL, $TermsAndConditionsAgreeText, $TermsAndConditionsName)
    {
        // Detail Fields
        // Create new group
        $oCleanDetailFields = new CompositeField();
        // Set the field group ID
        $oCleanDetailFields->setID('CreateDetails');
        // Add fields to the group
        $oCleanDetailFields->push(new LiteralField('Group1Title', '<div class="data-title-block"><img src="themes/lyc2012/img/fileicons/create_png.png" /><h2>Create your own event</h2><span> Enter as much detail as possible to make it easy for others to find and join your event.</span></div>'));
        $oCleanDetailFields->push(new TextField('Title', 'Event name'));
        $oCleanDetailFields->push(new LiteralField('Help', '<p class="help clear"> e.g. Location Name Beach Clean-up. Write something that describes what your event is all about.</p>'));
        $oCleanDetailFields->push(new SimpleHTMLEditorField('Description', 'Event details', '16', '18'));
        $oCleanDetailFields->push(new LiteralField('Help', '<p class="help clear"> Give additional details like what the organiser will provide (e.g. gloves, sacks), what participants will need to bring (e.g. food, drink, strong shoes) and anything else that will help people prepare for the event.</p>'));
        // Date Fields
        // Create new group
        $oCleanDateFields = new CompositeField();
        // Set the field group ID
        $oCleanDateFields->setID('CreateDateTime');
        //$oCleanDateFields->push(new LiteralField('Group3Title', '<div class="data-title-block"><img src="themes/lyc2012/img/s3.jpg" /><h2>When Is Your Event?</h2><span>Please enter these basic details, if you do not wish to provide more, you can submit the form after this stage.</span></div>'));
        $oCleanDateFields->push(new DatePickerField('FromDate', 'Start date'));
        $oCleanDateFields->push(new TextField('FromTime', 'Start time'));
        $oCleanDateFields->push(new DatePickerField('ToDate', 'Finish date'));
        $oCleanDateFields->push(new TextField('ToTime', 'Finish time'));
        //Location Fields
        // Create new group
        $oCleanLocationFields = new CompositeField();
        // Set the field group ID
        $oCleanLocationFields->setID('CreateLocation');
        //$oCleanLocationFields->push(new LiteralField('Group2Title', '<div class="data-title-block"><img src="themes/lyc2012/img/s2.jpg" /><h2>Where Is Your Event?</h2><span>Please enter these basic details, if you do not wish to provide more, you can submit the form after this stage.</span></div>'));
        $oCleanLocationFields->push(new DropdownField('Country', 'Country', Geoip::getCountryDropDown(), 'NZ'));
        //$oCleanLocationFields->push(new TextField('Region', 'Event Region'));
        $oCleanLocationFields->push(new TextField('LocationAddress', 'Location &nbsp;'));
        $oCleanLocationFields->push(new LiteralField('Help', '<p class="help clear">Either type the address of your event location above, or use the map below to zoom-in and drag and drop the red marker onto your event meeting point.</p>'));
        $oCleanLocationFields->push(new GoogleMapSelectableField('Location', "Location map", "-40.996484", "174.067383", "380px", "320px", "6"));
        $oCleanLocationFields->push(new HiddenField('LocationLongitude', 'Longitude (hide this)'));
        $oCleanLocationFields->push(new HiddenField('LocationLatitude', 'Latitude (hide this)'));
        //$oCleanLocationFields->push(new CheckboxField('LocationShowDetails', 'Give a More Detailed Location Description?'));
        //$oCleanLocationFields->push(new TextField('LocationDetails', 'Location Meeting Point Details'));
        //$oCleanLocationFields->push(new LiteralField('Help', '<p class="help clear">Give as much detail as possible. 500 word limit</p>'));
        //Admin Fields
        // Create new group
        $oCleanAdminFields = new CompositeField();
        // Set the field group ID
        $oCleanAdminFields->setID('CreateAdmin');
        $oCleanAdminFields->push(new TextField('Organisation', 'Name of organiser'));
        $oCleanAdminFields->push(new LiteralField('Help', "<p class='help clear'>Name of your school, community group or business. If none of these apply, just use your name.</p>"));
        $oCleanAdminFields->push(new SimpleImageField('EventImage', 'Upload logo/photo'));
        $oCleanAdminFields->push(new LiteralField('Help', "<p class='help clear'>Logo for your school, community group or business. If you don't have one, upload a photo that describes your event. Max file size 2MB</p>"));
        $oCleanAdminFields->push(new TextField('Facebooklink', 'Facebook Link for the event'));
        $oCleanAdminFields->push(new LiteralField('Help', '<p class="help clear">Optional. If you have a Facebook event for this event, copy the web address from your browser and paste it here.</p>'));
        $oCleanAdminFields->push(new CheckboxField('Agree', $TermsAndConditionsAgreeText));
        $oCleanAdminFields->push(new LiteralField('AgreeLink', '<div style="float: left; font-size: 10px; padding:10px;"><a href="#tc" id="tc_inline" class="fancyboxTC">View</a> or 
					 <a href="' . $TermsAndConditionsFileURL . '" Title="Download the ' . $TermsAndConditionsName . '">Download</a> the ' . $TermsAndConditionsName . '</div>' . '<div style="display:none"><div id="tc" style="width: 500px; padding-right: 20px">' . $TermsAndConditions . '</div></div>'));
        // Create new fieldset
        $oFields = new FieldSet();
        // Add the groups to the fieldset
        $oFields->push($oCleanDetailFields);
        $oFields->push($oCleanLocationFields);
        $oFields->push($oCleanDateFields);
        $oFields->push($oCleanAdminFields);
        // Create the form action
        $oAction = new FieldSet(new FormAction('createcleanup', 'Create Event'));
        /*
                $cleanupgroupFields = new CompositeField(
        			new LiteralField('Group1Title', '<div class="data-title-block"><img src="themes/lyc2012/img/s1.jpg" /><h2>Create your own event</h2><span>Please enter these basic details, if you do not wish to provide more, you can submit the form after this stage.</span></div>'),
        			new TextField('Title', 'Event name'),
        			new TextField('Subtitle', 'Event subtitle'),
        			new TextField('Organisation', 'Organisation Name'),
        			new TextField('Facebooklink', 'Facebook Link for the event'),
        			new DatePickerField('Date', 'Date'),
        			new DropdownField('Country', 'Country', Geoip::getCountryDropDown(), 'NZ'),
        			new TextField('Region', 'Event Region'),
        			new TextField('LocationAddress', 'Location Address'),
        			new GoogleMapSelectableMapField('Location', "Location of the Event", "-40.996484", "174.067383", "380px", "320px", "6"),
        			new HiddenField('LocationLongitude', 'Longitude (hide this)'),
        			new HiddenField('LocationLatitude', 'Latitude (hide this)'),
        			
        			new CheckboxField('LocationShowDetails', 'Give a More Detailed Location Description?'),
        			new TextField('LocationDetails', 'Location Meeting Point Details'),
        			new TextareaField('Description', 'Event Description', '30', '48'),
        			new LiteralField('Help', '<p class="help clear">Give as much detail as possible. 500 word limit</p>'),  
        			new CheckboxField('Agree', $TermsAndConditionsAgreeText),
        			new LiteralField('AgreeLink',
        					'<div style="float: left; font-size: 10px;"><a href="#tc" id="tc_inline" class="fancyboxTC">View</a> or 
        					 <a href="' . $TermsAndConditionsFileURL . '" Title="Download the ' . $TermsAndConditionsName . '">Download</a> the ' . $TermsAndConditionsName . '</div>' .
        					'<div style="display:none"><div id="tc" style="width: 500px; padding-right: 20px">' . $TermsAndConditions . '</div></div>')
                );
                $fields = new FieldSet($cleanupgroupFields);
                
        
                //add dropdown stuff
        
        
                $actions = new FieldSet(
                                new FormAction('createcleanup', 'Create')
                );*/
        //Debug::show($fields);
        //Debug::show($actions);
        //validation scripts
        Requirements::javascript("mysite/javascript/CreateFormVal.js");
//.........这里部分代码省略.........
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:101,代码来源:CreateForm.php

示例15: array

 function __construct($controller, $name)
 {
     //requirements
     Requirements::javascript('ecommerce/javascript/EcomOrderFormAddress.js');
     // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         Requirements::javascript('ecommerce/javascript/EcomOrderFormShipping.js');
         // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     }
     //set basics
     $order = ShoppingCart::current_order();
     $requiredFields = array();
     //  ________________ 1) Member + Address fields
     //find member
     $this->orderMember = $order->CreateOrReturnExistingMember(false);
     $this->loggedInMember = Member::currentUser();
     //strange security situation...
     if ($this->orderMember->exists() && $this->loggedInMember) {
         if ($this->orderMember->ID != $this->loggedInMember->ID) {
             if (!$this->loggedInMember->IsShopAdmin()) {
                 $this->loggedInMember->logOut();
             }
         }
     }
     $addressFieldsBilling = new FieldSet();
     //member fields
     if ($this->orderMember) {
         $memberFields = $this->orderMember->getEcommerceFields();
         $requiredFields = array_merge($requiredFields, $this->orderMember->getEcommerceRequiredFields());
         $addressFieldsBilling->merge($memberFields);
     }
     //billing address field
     $billingAddress = $order->CreateOrReturnExistingAddress("BillingAddress");
     $billingAddressFields = $billingAddress->getFields($this->orderMember);
     $requiredFields = array_merge($requiredFields, $billingAddress->getRequiredFields());
     $addressFieldsBilling->merge($billingAddressFields);
     //shipping address field
     $addressFieldsShipping = null;
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         $addressFieldsShipping = new FieldSet();
         //add the important CHECKBOX
         $useShippingAddressField = new FieldSet(new CheckboxField("UseShippingAddress", _t("OrderForm.USESHIPPINGADDRESS", "Use an alternative shipping address")));
         $addressFieldsShipping->merge($useShippingAddressField);
         //now we can add the shipping fields
         $shippingAddress = $order->CreateOrReturnExistingAddress("ShippingAddress");
         $shippingAddressFields = $shippingAddress->getFields($this->orderMember);
         //we have left this out for now as it was giving a lot of grief...
         //$requiredFields = array_merge($requiredFields, $shippingAddress->getRequiredFields());
         //finalise left fields
         $addressFieldsShipping->merge($shippingAddressFields);
     }
     $leftFields = new CompositeField($addressFieldsBilling);
     $leftFields->setID('LeftOrderBilling');
     $allLeftFields = new CompositeField($leftFields);
     $allLeftFields->setID('LeftOrder');
     if ($addressFieldsShipping) {
         $leftFieldsShipping = new CompositeField($addressFieldsShipping);
         $leftFieldsShipping->setID('LeftOrderShipping');
         $allLeftFields->push($leftFieldsShipping);
     }
     //  ________________  2) Log in / vs Create Account fields - RIGHT-HAND-SIDE fields
     $rightFields = new CompositeField();
     $rightFields->setID('RightOrder');
     //to do: simplify
     if (EcommerceConfig::get("EcommerceRole", "allow_customers_to_setup_accounts")) {
         if ($this->orderDoesNotHaveFullyOperationalMember()) {
             //general header
             if (!$this->loggedInMember) {
                 $rightFields->push(new LiteralField('MemberInfo', '<p class="message good">' . _t('OrderForm.MEMBERINFO', 'If you are already have an account then please') . " <a href=\"Security/login/?BackURL=" . urlencode($controller->Link()) . "\">" . _t('OrderForm.LOGIN', 'log in') . '</a>.</p>'));
             }
             $passwordField = new ConfirmedPasswordField('Password', _t('OrderForm.PASSWORD', 'Password'));
             //login invite right on the top
             if (EcommerceConfig::get("EcommerceRole", "automatic_membership")) {
                 $rightFields->push(new HeaderField('CreateAnAccount', _t('OrderForm.CREATEANACCONTOPTIONAL', 'Create an account (optional)'), 3));
                 //allow people to purchase without creating a password
                 $passwordField->setCanBeEmpty(true);
             } else {
                 $rightFields->push(new HeaderField('SetupYourAccount', _t('OrderForm.SETUPYOURACCOUNT', 'Setup your account'), 3));
                 //dont allow people to purchase without creating a password
                 $passwordField->setCanBeEmpty(false);
             }
             $requiredFields[] = 'Password[_Password]';
             $requiredFields[] = 'Password[_ConfirmPassword]';
             Requirements::customScript('jQuery("#ChoosePassword").click();', "EommerceChoosePassword");
             // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
             $rightFields->push(new LiteralField('AccountInfo', '<p>' . _t('OrderForm.ACCOUNTINFO', 'Please <a href="#Password" class="choosePassword">choose a password</a>; this will allow you can log in and check your order history in the future.') . '</p>'));
             $rightFields->push(new FieldGroup($passwordField));
         } else {
             if ($this->loggedInMember) {
                 $rightFields->push(new LiteralField('LoginNote', "<p class=\"message good\">" . _t("Account.LOGGEDIN", "You are logged in as ") . $this->loggedInMember->FirstName . ' ' . $this->loggedInMember->Surname . ' (' . $this->loggedInMember->Email . ').</p>'));
             }
         }
         if ($this->orderMember->exists()) {
             if ($this->loggedInMember) {
                 if ($this->loggedInMember->ID != $this->orderMember->ID) {
                     $rightFields->push(new LiteralField('OrderAddedTo', "<p class=\"message good\">" . _t("Account.ORDERADDEDTO", "Order will be added to ") . $this->orderMember->FirstName . ' ' . $this->orderMember->Surname . ' (' . $this->orderMember->Email . ').</p>'));
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:101,代码来源:OrderFormAddress.php


注:本文中的CompositeField::setID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。