public function __construct($controller, $name, CheckoutComponentConfig $config) { $this->config = $config; $fields = $config->getFormFields(); if ($text = $this->config()->get('submit_button_text')) { $submitBtnText = $text; } else { $submitBtnText = _t('CheckoutPage.ProceedToPayment', 'Proceed to payment'); } $actions = FieldList::create(FormAction::create('checkoutSubmit', $submitBtnText)); $validator = CheckoutComponentValidator::create($this->config); // For single country sites, the Country field is readonly therefore no need to validate if (SiteConfig::current_site_config()->getSingleCountry()) { $validator->removeRequiredField("ShippingAddressCheckoutComponent_Country"); $validator->removeRequiredField("BillingAddressCheckoutComponent_Country"); } parent::__construct($controller, $name, $fields, $actions, $validator); //load data from various sources $this->loadDataFrom($this->config->getData(), Form::MERGE_IGNORE_FALSEISH); if ($member = Member::currentUser()) { $this->loadDataFrom($member, Form::MERGE_IGNORE_FALSEISH); } if ($sessiondata = Session::get("FormInfo.{$this->FormName()}.data")) { $this->loadDataFrom($sessiondata, Form::MERGE_IGNORE_FALSEISH); } }
public function __construct($controller, $name, CheckoutComponentConfig $config) { $this->config = $config; $fields = $config->getFormFields(); $actions = new FieldList(FormAction::create('checkoutSubmit', _t('CheckoutForm', 'Proceed to payment'))); $validator = new CheckoutComponentValidator($this->config); parent::__construct($controller, $name, $fields, $actions, $validator); //load data from various sources $this->loadDataFrom($this->config->getData(), Form::MERGE_IGNORE_FALSEISH); if ($member = Member::currentUser()) { $this->loadDataFrom($member, Form::MERGE_IGNORE_FALSEISH); } if ($sessiondata = Session::get("FormInfo.{$this->FormName()}.data")) { $this->loadDataFrom($sessiondata, Form::MERGE_IGNORE_FALSEISH); } }