Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Multistep Form Not Progressing (tutorial out of date)?


Reply


3 Posts   545 Views

Avatar
Bimble

Community Member, 16 Posts

15 January 2014 at 8:12am

Edited: 15/01/2014 8:13am

I can't get the tutorial listed in the Multistep Form module to work http://addons.silverstripe.org/add-ons/silverstripe/multiform
A couple of problems are simple enough to debug (replacing some private to public and changing FieldSet to FieldList).

However, I'm now stuck. When you click on "next", I get "page not found" with no errors in the httpd error logs.

I posted this same problem before on my code in another forum with no replies. So I thought if I posted on the tutorial code then at least the example code could be updated if a solution is found for 3.x :)

class BSCMultiForm_Controller extends Page_Controller {
private static $allowed_actions = array('index');
public function index() {
$this->Content = $this->BCSMultiForm();
return $this->render();
}
}

class BCSMultiForm extends MultiForm {
public static $start_step = 'BCSPersonalDetailsFormStep';
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 == 'BCSPersonalDetailsFormStep') {
$member = new Member();
$data = $step->loadData();
if($data) {
$member->update($data);
$member->write();
}
}
if($step->class == 'BCSOrganisationDetailsFormStep') {
$organisation = new Organisation();
$data = $step->loadData();
if($data) {
$organisation->update($data);
if($member && $member->ID) {
$organisation->MemberID = $member->ID;
}
$organisation->write();
}
}
// Shows the step data (unserialized by loadData)
// Debug::show($step->loadData());
}
}
$controller = $this->getController();
$controller->redirect($controller->Link() . 'finished');
}
}

class BCSPersonalDetailsFormStep extends MultiFormStep {
public static $next_steps = 'BCSOrganisationDetailsFormStep';
function getFields() {
return new FieldList(
new TextField('FirstName', 'First name'),
new TextField('Surname', 'Surname')
);
}
}

class BCSOrganisationDetailsFormStep extends MultiFormStep {
public static $is_final_step = true;
}

Avatar
martimiz

Forum Moderator, 1132 Posts

21 January 2014 at 10:06am

The tutorial at least isn't up to date for SilverStripe 3.1, like you already noticed. It would probably be a good idea to report this as an issue here:

https://github.com/silverstripe/silverstripe-multiform/issues

Avatar
Bimble

Community Member, 16 Posts

22 January 2014 at 1:36am

Thanks Martimiz, I have done so now.