상속: extends RequiredFields
 public function testValidation()
 {
     $validator = new OrderActionsForm_Validator('PaymentMethod');
     $form = new OrderActionsForm(ModelAsController::controller_for($this->checkoutPage), 'ActionsForm', $this->order);
     $validator->setForm($form);
     Form::set_current_action('dopayment');
     $validator->php(array('OrderID' => $this->order->ID, 'PaymentMethod' => 'Dummy', 'type' => 'visa', 'name' => 'Tester Mc. Testerson', 'number' => '4242424242424242'));
     $requiredCount = 0;
     foreach ($validator->getErrors() as $error) {
         if ($error['messageType'] == 'required') {
             $requiredCount++;
         }
     }
     // 3 required fields missing
     $this->assertEquals(3, $requiredCount);
 }
 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::getSupportedGateways();
         //remove manual gateways
         foreach ($gateways as $gateway => $gatewayname) {
             if (GatewayInfo::isManual($gateway)) {
                 unset($gateways[$gateway]);
             }
         }
         if (!empty($gateways)) {
             $fields->push(HeaderField::create("MakePaymentHeader", _t("OrderActionsForm.MakePayment", "Make Payment")));
             $outstandingfield = Currency::create();
             $outstandingfield->setValue($order->TotalOutstanding(true));
             $fields->push(LiteralField::create("Outstanding", _t('Order.OutstandingWithAmount', 'Outstanding: {Amount}', '', array('Amount' => $outstandingfield->Nice()))));
             $fields->push(OptionsetField::create('PaymentMethod', _t("OrderActionsForm.PaymentMethod", "Payment Method"), $gateways, key($gateways)));
             if ($ccFields = $this->getCCFields($gateways)) {
                 if ($this->config()->include_jquery) {
                     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.min.js');
                 }
                 Requirements::javascript(SHOP_DIR . '/javascript/OrderActionsForm.js');
                 $fields->push($ccFields);
             }
             $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, OrderActionsForm_Validator::create(array('PaymentMethod')));
     $this->extend("updateForm", $order);
 }