Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

Getting Member_Validator to work


Go to End


1368 Views

Avatar
david.brunelle

Community Member, 5 Posts

29 July 2011 at 12:58pm

I'm trying to do some front end member registration, using the examples given in the English version of "SilverStripe - The Complete Guide to CMS Development" (See page 187). The examples in the book and the documentation for the class (http://api.silverstripe.org/2.4/sapphire/security/Member_Validator.html) seem to indicate the Member_Validator should check for an existing member using the provided email address.

This doesn't seem to be the case. Anyone know why Member_Validator may not be checking for an existing member? Here's code, reduced for brevity:

<?php
class FundraiserContact extends Member {
	static $db = array(
		"PhoneNumber" => "Varchar(100)",
		"JobTitle" => "Varchar(255)"
	);
	
	public function getFrontendFields() {
		$fields = $this->scaffoldFormFields(array(
			'restrictFields' => array(
				'FirstName',
				'Surname',
				'JobTitle',
				'PhoneNumber',
				'Email',
				'Password'
			),
			'fieldClasses' => array(
				'Email' => 'EmailField',
				'Password' => 'ConfirmedPasswordField'
			)
		));
		
		return $fields;
	}

}

<?php 
class FundraiserContactDetailStep extends MultiFormStep {
	...

	function getValidator() {
		return new Member_Validator(
			'FirstName',
			'Surname',
			'PhoneNumber',
			'Email',
			'Password'
		);
	}
}