CheckoutForm::__construct PHP Method

__construct() public method

public __construct ( $controller, $name, CheckoutComponentConfig $config )
$config CheckoutComponentConfig
    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);
        }
    }

Usage Example

 public function __construct($controller, $name, CheckoutComponentConfig $config)
 {
     parent::__construct($controller, $name, $config);
     $this->orderProcessor = Injector::inst()->create('OrderProcessor', $config->getOrder());
 }