Jump to:

22997 Posts in 11620 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » redirect thanks page create Problem

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1310 Views
  • amarbhanu
    Avatar
    Community Member
    57 Posts

    redirect thanks page create Problem Link to this post

    when i redirect to thanks page then

    msg :

    Sorry, it seems you were trying to access a page that doesn't exist.

    Please check the spelling of the URL you were trying to access and try again.

    so, created a thanks page "http://localhost/SilverStripe-v2.3.1/thanks/" then page redirect well but problem is that i created by admin content page so this page also show when we navigate a this site so please help me without navigation show create a thanks page................

    me code is :

    <?php
    class RegistrationForm extends Page {

    }

       class MyObject extends DataObject {
        static $db = array(
          'Typeofenquiry' => "Enum('Please select,Business Development,Hall Hire,Events,Membership,Accounts,Library & Archives,General','Please select')"
        );
       }
       
    class RegistrationForm_Controller extends Page_Controller {

       // Make sure you set this to the right group.
       // See http://doc.silverstripe.com/doku.php?do=show&id=recipes%3Aforms
       private $defaultGroupID = 2;

       /**
       * This function lets you put a form on your page, using $Form.
       */
       
       
       function Form() {
          return new Form($this, "Form", new FieldSet(

             // List your fields here
             new TextField("Name", "name"),
             new TextField("JobTitle","Job title"),
             new TextField("CompanyName","Company name"),
             new TextField("Address","Address"),
             new TextField("Post code","Post code"),
             new TextField("Telephone","Telephone"),
             new TextField("Mobile","Mobile"),
             new EmailField("Email", "Email"),
             new TextField("Enquiry","Enquiry"),
             new TextField("TypeOfFunction","Type of function"),
             new TextField("NumbersAttending","Numbers attending"),
             new TextField("PreferedDates","Prefered dates"),
             new DropdownField('Typeofenquiry',
              'Type of enquiry',
              singleton('MyObject')->dbObject('Typeofenquiry')->enumValues())
             

          ), new FieldSet(

             // List the action buttons here
             new FormAction("SignupAction", "Sign up")

          ), new RequiredFields(
             "Email", "Name","Enquiry","Telephone"

             // List the required fields here: "Email", "FirstName"

          ),
          $field = new DropdownField(
              'Typeofenquiry',
              'Typeofenquiry',
              singleton('MyObject')->dbObject('Typeofenquiry')->enumValues()
             )
          );
       }

       /**
       * This function is called when the user submits the form.
       */
       function SignupAction($data, $form) {

          // Create a new Member object and load the form data into it
          $member = new Member();
          $form->saveInto($member);

          // Write it to the database. This needs to happen before we add it to a group
          $member->write();

          // Add the member to group. (Check if it exists first)
          if($group = DataObject::get_one('Group', "ID = $this->defaultGroupID")) {

             $member->Groups()->add($group);
             // Redirect to a page thanking people for registering
             Director::redirect('thanks-for-registering/');
             //Director::redirect('http://localhost/SilverStripe-v2.3.1/thanks/');

          }else{

             // Redirect to a failure page
             Director::redirect('registration-failed/');

          }
          
          

       }
    }

    ?>

  • CHD
    Avatar
    Community Member
    217 Posts

    Re: redirect thanks page create Problem Link to this post

    well to hide the page from navigation, you just use the checkbox under the "behaviour" tab to remove it from site search and site nav.

    also, this may come in handy for anybody who wants to easily include forms in a sidebar or any other area of the site, without controlling a hidden page:

    http://www.clickheredigital.co.uk/blog/how-to-include-a-silverstripe-form-on-any-every-page/

    it also has an easy "query database for existing member" function that isn't covered in the form tutorials...

    1310 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.