Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class RegistrationForm extends Page {
- }
- class RegistrationForm_Controller extends Page_Controller {
- // Registration Form
- function Form() {
- return new Form($this, "Form", new FieldSet(
- //List of fields
- new TextField("FirstName", "First Name"),
- new TextField("Surname", "Last Name"),
- new TextField("UserName", "User Name"),
- new EmailField("Email", "Email Address"),
- new ConfirmedPasswordField("Password", "Password"),
- new TextField("Address", "Address"),
- new TextField("Suburb", "Suburb"),
- new TextField("City", "City"),
- new DateField("DateOfBirth", "Date of Birth"),
- new PhoneNumberField("HomePhone", "Home phone"),
- new PhoneNumberField("MobilePhone", "Mobile phone")
- ), new FieldSet(
- new FormAction("register", "Register")
- ), new RequiredFields(
- "FirstName", "Surname", "UserName", "Email", "Password", "Address", "Suburb", "City", "HomePhone"
- ));
- }
- function register($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
- $member->write();
- // Add the member to a group
- if($group = DataObject::get_one('Group', "Code = 'registered-users'")){
- $member->Groups()->add($group);
- }
- // Redirect to Thank You page
- Director::redirect('registration-successful/');
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement