/** * @param Controller $controller * @param String $name * @param Order $order * @param String */ function __construct(Controller $controller, $name, Order $order, $returnToLink = '') { $fields = new FieldList(new HiddenField('OrderID', '', $order->ID)); if ($returnToLink) { $fields->push(new HiddenField("returntolink", "", convert::raw2att($returnToLink))); } $bottomFields = new CompositeField(); $bottomFields->addExtraClass('bottomOrder'); if ($order->Total() > 0) { $paymentFields = EcommercePayment::combined_form_fields($order->getTotalAsMoney()->NiceLongSymbol(false), $order); foreach ($paymentFields as $paymentField) { $bottomFields->push($paymentField); } if ($paymentRequiredFields = EcommercePayment::combined_form_requirements($order)) { $requiredFields = array_merge($requiredFields, $paymentRequiredFields); } } else { $bottomFields->push(new HiddenField("PaymentMethod", "", "")); } $fields->push($bottomFields); $actions = new FieldList(new FormAction('dopayment', _t('OrderForm.PAYORDER', 'Pay balance'))); $requiredFields = array(); $validator = OrderForm_Payment_Validator::create($requiredFields); $form = parent::__construct($controller, $name, $fields, $actions, $validator); //extension point $this->extend('updateFields', $fields); $this->setFields($fields); $this->extend('updateActions', $actions); $this->setActions($actions); $this->extend('updateValidator', $validator); $this->setValidator($validator); $this->setFormAction($controller->Link($name)); $oldData = Session::get("FormInfo.{$this->FormName()}.data"); if ($oldData && (is_array($oldData) || is_object($oldData))) { $this->loadDataFrom($oldData); } $this->extend('updateOrderForm_Payment', $this); }
function __construct($controller, $name, $order, $returnToLink = '') { $fields = new FieldSet(new HiddenField('OrderID', '', $order->ID)); if ($returnToLink) { $fields->push(new HiddenField("returntolink", "", convert::raw2att($returnToLink))); } $totalAsCurrencyObject = $order->TotalAsCurrencyObject(); $totalOutstandingAsMoneyObject = $order->TotalOutstandingAsMoneyObject(); $paymentFields = Payment::combined_form_fields($totalOutstandingAsMoneyObject->Nice()); foreach ($paymentFields as $paymentField) { if ($paymentField->class == "HeaderField") { $paymentField->setTitle(_t("OrderForm.MAKEPAYMENT", "Make Payment")); } $fields->push($paymentField); } $requiredFields = array(); if ($paymentRequiredFields = Payment::combined_form_requirements()) { $requiredFields = array_merge($requiredFields, $paymentRequiredFields); } $actions = new FieldSet(new FormAction('dopayment', _t('OrderForm.PAYORDER', 'Pay balance'))); $form = parent::__construct($controller, $name, $fields, $actions, $requiredFields); 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); } $this->setFormAction($controller->Link($name)); $this->extend('updateOrderFormPayment', $this); }