SilverStripe MultiForm not working
I have installed and configured SilverStripe on my server. I installed the MultiForm module and followed the instructions in the module's documentation.
After following the instructions, I still don't see any new page types on my CMS portal.
I've also tried db/build?flush=1
and dev/build?flush=1
, but it doesn't matter.
I created the following files in the directory mysite/code/
SponsorSignupForms.php
class SponsorSignupForms extends MultiForm{
protected static $start_step = 'CompanyDetailsStep';
}
CompanyDetailsStep.php
class CompanyDetailsStep extends MultiFormStep{
public static $next_steps = 'ContactDetailsStep';
function getFields()
{
$fields = singleton('Member')->getFrontendFields();
return $fields;
}
function getValidator()
{
return new Member_Validator('FirstName', 'Surname', 'Email', 'Password');
}
}
ContactDetailsStep.php
class ContactDetailsStep extends MultiFormStep{
public static $is_final_step = true;
function getFields()
{
$fields = singleton('Reference')->getFrontendFields();
return $fields;
}
}
How do I get these custom MultiForms to work and appear as generated pages?
source to share
Of course, you don't see the new page type in the list of available pages, you only see the subclasses SiteTree
there, MultiFormStep
is "just" a subclass DataObject
.
You can connect your form to every page you want manually, but you can also create a new page type for your form and include the form in your controller and template, see the readme for MultiForm :
class MyFormPage extends Page
{
}
class MyFormPageController extends Page_Controller
{
//
private static $allowed_actions = array(
'SponsorSignupForms',
'finished'
);
public function SponsorSignupForms() {
return new SponsorSignupForms($this, 'Form');
}
public function finished() {
return array(
'Title' => 'Thank you for your submission',
'Content' => '<p>You have successfully submitted the form!</p>'
);
}
}
In the template, just enter the form:
<% if $SponsorSignupForms %>
$SponsorSignupForms
<% end_if %>
and you should now see the shape.
source to share