Hello,
I have 2 classes : "ExtMember" and "ExtMemberAdmin"
+ ExtMember.php :
class ExtMember extends Member {
static $db = array(
'extName' => 'Varchar'
);
}
+ ExtMemberAdmin.php :
class ExtMemberAdmin extends ModelAdmin {
static $url_segment = 'extMember';
static $managed_models = array(
'ExtMember'
);
}
When i add a new "ExtMember" member with an already registered email, this doesn't work : the "Add" button turns, turns and turns infinitely.
If i use Firebug to view the response, i have this :
ERROR [User Error]: Uncaught ValidationException:
IN POST /silverstripe-v2.4.1/admin/extMember/ExtMember/AddForm?action_doCreate=Ajout
Line 611 in /var/www/silverstripe-v2.4.1/sapphire/security/Member.php
Source
======
602: 'Member',
603: sprintf(
604: "\"%s\" = '%s' %s",
605: $identifierField,
606: Convert::raw2sql($this->$identifierField),
607: $idClause
608: )
609: );
610: if($existingRecord) {
* 611: throw new ValidationException(new ValidationResult(false, sprintf(
612: _t(
613: 'Member.ValidationIdentifierFailed',
614: 'Can\'t overwrite existing member #%d with identical identifier (%s = %s))',
615: PR_MEDIUM,
616: 'The values in brackets show a fieldname mapped to a value, usually denoting an existing email
address'
617: ),
Trace
=====
Member->onBeforeWrite()
line 936 of DataObject.php
DataObject->write()
line 859 of ModelAdmin.php
ModelAdmin_CollectionController->doCreate(Array,Form,SS_HTTPRequest)
line 300 of Form.php
Form->httpSubmission(SS_HTTPRequest)
line 137 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
line 155 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
line 149 of Controller.php
Controller->handleRequest(SS_HTTPRequest)
line 155 of RequestHandler.php
RequestHandler->handleRequest(SS_HTTPRequest)
line 149 of Controller.php
Controller->handleRequest(SS_HTTPRequest)
line 281 of Director.php
Director::handleRequest(SS_HTTPRequest,Session)
line 124 of Director.php
Director::direct(/admin/extMember/ExtMember/AddForm)
line 127 of main.php
I would like to know how to validate (only a unique email) "email" in a modelAdmin (like the email Member validation in Security Tab) ?
Thank you for your help,