Created
April 9, 2013 06:37
-
-
Save ss23/5343445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class HomePage extends Page { | |
} | |
class HomePage_Controller extends Page_Controller { | |
static $allowed_actions = array('BuyForm', 'doBuy', 'complete', 'failed', 'beforeBuy'); | |
public function BuyForm() { | |
$fields = new FieldList( | |
new FieldGroup('Customer Details', | |
TextField::create('FirstName', 'First name')->setAttribute('required', true), | |
new TextField('LastName', 'Last name'), | |
new EmailField('Email', 'e-mail Address'), | |
new PhoneNumberField('Phone') | |
), | |
new FieldGroup('Terms & Conditions', | |
new LiteralField('TC', '<div class="typography">' . $this->getActiveDeal()->TermsAndConditions . '</div>'), | |
new CheckboxField('TCAgree', 'I accept the terms & conditions') | |
), | |
new HiddenField('DealID', 'DealID', $this->getActiveDeal()->ID) | |
); | |
$actions = new FieldList( | |
new FormAction('doBuy', 'Next'), | |
new LabelField('note', 'You will be directed to a secure DPS page, then returned to this website.') | |
); | |
$required = new RequiredFields(array('FirstName', 'LastName', 'Email', 'Phone', 'TCAgree', 'DealID')); | |
$form = new Form($this, __FUNCTION__, $fields, $actions, $required); | |
$form->loadDataFrom($this->request->postVars()); | |
return $form; | |
} | |
public function doBuy($data, $form) { | |
var_dump($form->validate()); | |
die('called'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment