anjnkmr
anjnkmr

Reputation: 868

SilverStripe MultiForm not working

I installed and configured SilverStripe on my server. I installed the MultiForm module and followed the instructions in the module documentation.

After following the instructions I still don't see any new page type in my CMS Portal.

I also tried db/build?flush=1 & dev/build?flush=1 but it doesn't make a difference.

I Created the Following files in mysite/code/ directory

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 working and appearing as creatable pages?

Upvotes: 3

Views: 359

Answers (1)

wmk
wmk

Reputation: 4626

Of course you don't see any new page type in the list of available pages, you will only see subclasses of SiteTree there, MultiFormStep is "just" a subclass of DataObject.

You can plug your form to every page you want manually, but you also can create a new page type for your form and include the Form in your Controller and Template, see readme of 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 include the form:

<% if $SponsorSignupForms %>
    $SponsorSignupForms
<% end_if %>

and you should see the form now.

Upvotes: 2

Related Questions