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