2010-03-03 23:24:02 +01:00
|
|
|
<?php
|
|
|
|
class TestMultiForm extends MultiForm {
|
2010-05-11 05:31:18 +02:00
|
|
|
public static $start_step = 'TestMultiFormStepOne';
|
2010-03-03 23:24:02 +01:00
|
|
|
|
|
|
|
function finish($data, $form) {
|
|
|
|
parent::finish($data, $form);
|
|
|
|
|
|
|
|
$savedSteps = $this->getSavedSteps();
|
|
|
|
|
|
|
|
$savedData = array();
|
|
|
|
foreach($savedSteps as $step) {
|
|
|
|
$savedData = array_merge($savedData, $step->loadData());
|
|
|
|
}
|
|
|
|
|
|
|
|
$fields = new FieldSet();
|
|
|
|
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
|
|
|
|
|
|
|
foreach($savedData as $key=>$value) {
|
|
|
|
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
|
|
|
}
|
|
|
|
|
2010-03-04 03:36:29 +01:00
|
|
|
Session::set("MultiFormMessage", "Your information has been submitted.");
|
|
|
|
|
2010-03-03 23:24:02 +01:00
|
|
|
Director::redirect(Director::BaseURL() . $this->Controller()->URLSegment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TestMultiFormStepOne extends MultiFormStep {
|
2010-05-11 05:36:45 +02:00
|
|
|
public static $next_steps = 'TestMultiFormStepTwo';
|
2010-03-03 23:24:02 +01:00
|
|
|
|
|
|
|
function getFields() {
|
|
|
|
return new FieldSet(
|
|
|
|
new TextField('FirstName', 'First name'),
|
|
|
|
new TextField('Surname', 'Surname')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class TestMultiFormStepTwo extends MultiFormStep {
|
2010-05-11 05:36:45 +02:00
|
|
|
public static $next_steps = 'TestMultiFormStepThree';
|
2010-03-03 23:24:02 +01:00
|
|
|
|
|
|
|
function getFields() {
|
|
|
|
|
|
|
|
return new FieldSet(
|
|
|
|
new TextField('Email', 'Email'),
|
|
|
|
new TextField('Address', 'Address')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class TestMultiFormStepThree extends MultiFormStep {
|
|
|
|
protected static $is_final_step = true;
|
|
|
|
|
|
|
|
function getFields() {
|
|
|
|
$form = $this->getForm();
|
|
|
|
$savedSteps = $form->getSavedSteps();
|
|
|
|
|
|
|
|
$savedData = array();
|
|
|
|
foreach($savedSteps as $step) {
|
|
|
|
$savedData = array_merge($savedData, $step->loadData());
|
|
|
|
}
|
|
|
|
|
|
|
|
$fields = new FieldSet();
|
|
|
|
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
|
|
|
|
|
|
|
foreach($savedData as $key=>$value) {
|
|
|
|
if(preg_match("/_copy$/", $key)) continue;
|
|
|
|
|
|
|
|
$fields->push(new LiteralField($key . '_copy', "<p><strong>$key</strong> $value</p>"));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|