Jump to:

5522 Posts in 1734 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Ragistation form create but admin page have problem

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

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

    Ragistation form create but admin page have problem Link to this post

    i used help for coding
    http://doc.silverstripe.org/doku.php?id=recipes:forms

    and code is :
    <?php
    class RegistrationForm extends Page {
    }

    class RegistrationForm_Controller extends Page_Controller {

       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("FirstName", "First name"),
             new TextField("Surname"),
             new EmailField("Email", "Email address")
             

          ), new FieldSet(

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

          ), new RequiredFields(
             

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

          ));
       }

       /**
       * 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/');

          }else{

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

          }

       }
    }
    ?>

    i have two problem:
    1. dropdown list create problem.
    2. data base have data but how to access this data.

    i haven't any idea so please help me and send some help of links and suggestion please send....

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: Ragistation form create but admin page have problem Link to this post

    You can view Members in the Security Section in the CMS.

    If you want to get a list of Members on the site you just need to DataObject::get('Member');

    1088 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.