2010-03-10 21:20:44 +01:00
|
|
|
<?php
|
|
|
|
|
2016-07-01 04:37:50 +02:00
|
|
|
use SilverStripe\ORM\DataObject;
|
2016-07-20 00:34:52 +02:00
|
|
|
use SilverStripe\Security\Member;
|
2016-09-07 07:10:55 +02:00
|
|
|
use SilverStripe\Forms\TextField;
|
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
|
2016-07-01 04:37:50 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class Page2MultiForm extends MultiForm
|
|
|
|
{
|
2016-07-20 00:34:52 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
public static $start_step = 'Page2PersonalDetailsFormStep';
|
2016-07-20 00:34:52 +02:00
|
|
|
|
2015-12-17 21:20:49 +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();
|
|
|
|
}
|
|
|
|
}
|
2010-03-10 21:20:44 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2010-03-10 21:20:44 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
// Debug::show($step->loadData()); // Shows the step data (unserialized by loadData)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$controller = $this->getController();
|
|
|
|
$controller->redirect($controller->Link() . 'finished');
|
|
|
|
}
|
|
|
|
}
|
2010-03-10 21:20:44 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class Page2PersonalDetailsFormStep extends MultiFormStep
|
|
|
|
{
|
2016-07-20 00:34:52 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
2016-07-20 00:34:52 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
public function getFields()
|
|
|
|
{
|
|
|
|
return new FieldList(
|
|
|
|
new TextField('FirstName', 'First name'),
|
|
|
|
new TextField('Surname', 'Surname')
|
|
|
|
);
|
|
|
|
}
|
2010-03-10 21:20:44 +01:00
|
|
|
}
|
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class Page2OrganisationDetailsFormStep extends MultiFormStep
|
|
|
|
{
|
2016-07-20 00:34:52 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
public static $is_final_step = true;
|
2010-03-10 21:20:44 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
public function getFields()
|
|
|
|
{
|
|
|
|
return new FieldList(
|
|
|
|
new TextField('OrganisationName', 'Organisation Name')
|
|
|
|
);
|
|
|
|
}
|
2010-03-10 21:20:44 +01:00
|
|
|
}
|