Hi there,
I need to create a form that posts data to an external url. When the user clicks submit, it must transmit the data and open the external url up in a seperate window.
This is what i have so far, but i just cant get the form to work properly:
class IBPayment extends Page {
public static $db = array(
);
}
class IBPayment_Controller extends Page_Controller {
function IBPaymentForm() {
//Create the fields that will be used
$fields = new FieldSet (
new OptionsetField ('liddesc', 'What are you paying for', array (
'Scuba dive course' => 'Scuba dive course',
'Casual dive' => 'Casual dive',
'Shark cage diving' => 'Shark cage diving',
'Equipment hire' => 'Equipment hire',
'Equipment purchase' => 'Equipment purchase'
)),
new TextField('MerchCustom',"Unique Payment reference"),
new TextField('lidprice',"Amount to pay")
);
// Create actions
$actions = new FieldSet(
new FormAction('Submit','Pay Now'));
// Create validator
$validator = new RequiredFields('MerchCustom', 'lidprice', 'liddesc' );
// Return form
return new Form($this, 'IBPaymentForm', $fields, $actions, $validator);
// Set the destination URL
//$IBPaymentForm->setFormAction('http://blah/test.html');
function Submit($data,$form) {
$IBPaymentForm->setFormAction('http://blah/test.html');
return Director::redirectBack();
}
}
}