I've created a custom form that uses its own template, however the on submit errors don't seem to pass back into the form;
Here is the submit action
function submit($data, $form) {
$application = new UserApplication();
//Check Against Existing Approved Users
$SQL_email = Convert::raw2sql($data['Email']);
$existingMember = DataObject::get_one('Member', "Email = '$SQL_email'");
if($existingMember) {
if($existingMember->ID != $member->ID) {
$form->addErrorMessage('Blurb',
_t(
'RegistrationForm.EMAILEXISTS',
'Sorry, that email address already exists. Please choose another.'
),
'bad'
);
Director::redirectBack();
return;
}
}
//Create User Application
$form->saveInto($application);
$application->write();
//E-mail Registration Form Contents:
//Set data
Director::redirect(Director::baseURL(). "new-user-registration-thank-you/");
}
and here is the template
<form $FormAttributes class="container_12">
<% if Message %>
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
<% else %>
<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
<% end_if %>
<div class="grid_4" id="User">
<h3>Personal Information</h3>
<p>Used to set up your ophoriatoys.com account</p>
<fieldset>
<div id="FirstName" class="field text">
<label for="$FormName_FirstName">First name</label>
<div class="middleColumn">
$dataFieldByName(FirstName)
</div>
</div>
<div id="Surname" class="field text">
<label for="$FormName_Surname">Last Name</label>
<div class="middleColumn">
$dataFieldByName(Surname)
</div>
</div>
<div id="Email" class="field email">
<label for="$FormName_Email">Email</label>
<div class="middleColumn">
$dataFieldByName(Email)
</div>
</div>
$dataFieldByName(Password)
$dataFieldByName(SecurityID)
$Title
</fieldset>
</div>
<% if Actions %>
<div class="Actions">
<% control Actions %>$Field<% end_control %>
</div>
<% end_if %>
</form>