2010-03-10 21:20:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Page2MultiForm extends MultiForm {
|
|
|
|
|
2010-05-11 05:31:18 +02:00
|
|
|
public static $start_step = 'Page2PersonalDetailsFormStep';
|
2010-03-10 21:20:44 +01:00
|
|
|
|
|
|
|
public function finish($data, $form) {
|
|
|
|
parent::finish($data, $form);
|
|
|
|
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
|
|
|
|
if($steps) {
|
|
|
|
foreach($steps as $step) {
|
|
|
|
if($step->class == 'Page2PersonalDetailsFormStep') {
|
|
|
|
$member = new Member();
|
|
|
|
$data = $step->loadData();
|
|
|
|
if($data) {
|
|
|
|
$member->update($data);
|
|
|
|
$member->write();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($step->class == 'Page2OrganisationDetailsFormStep') {
|
|
|
|
$organisation = new Organisation();
|
|
|
|
$data = $step->loadData();
|
|
|
|
if($data) {
|
|
|
|
$organisation->update($data);
|
|
|
|
if($member && $member->ID) $organisation->MemberID = $member->ID;
|
|
|
|
$organisation->write();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Debug::show($step->loadData()); // Shows the step data (unserialized by loadData)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$controller = $this->getController();
|
|
|
|
$controller->redirect($controller->Link() . 'finished');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Page2PersonalDetailsFormStep extends MultiFormStep {
|
|
|
|
|
2010-05-11 05:36:45 +02:00
|
|
|
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
2010-03-10 21:20:44 +01:00
|
|
|
|
|
|
|
function getFields() {
|
2012-06-29 14:27:32 +02:00
|
|
|
return new FieldList(
|
2010-03-10 21:20:44 +01:00
|
|
|
new TextField('FirstName', 'First name'),
|
|
|
|
new TextField('Surname', 'Surname')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class Page2OrganisationDetailsFormStep extends MultiFormStep {
|
|
|
|
|
2010-05-11 05:36:45 +02:00
|
|
|
public static $is_final_step = true;
|
2010-03-10 21:20:44 +01:00
|
|
|
|
|
|
|
function getFields() {
|
2012-06-29 14:27:32 +02:00
|
|
|
return new FieldList(
|
2010-03-10 21:20:44 +01:00
|
|
|
new TextField('OrganisationName', 'Organisation Name')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|