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

addErrorMessage to Form shows message on wrong place


Go to End


2 Posts   3695 Views

Avatar
Matze0681

Community Member, 25 Posts

11 November 2010 at 1:29pm

hi,

i try to add a custom form-validation message for "Email is already in use" to a Form. Validation works fine with the following code, but the message does not appear at the correct place(next to the Field OverwriteEmail) but below all the form Fields on the bottom of the form. What did i do wrong?

thanks in advance for your help!

	$existingMember = DataObject::get_one('Customer',"Email = '".$data['OverwriteEmail']."'");
 	if($existingMember) {
        $form->addErrorMessage('OverwriteEmail',
           _t(
              'QuoteBuilder.EMAILEXISTS',
              'Sorry, that email address already exists. Please choose another.'
           ),
           'bad'
        );

        Director::redirectBack();
        return;
    }

Avatar
Rodolfo

Community Member, 11 Posts

19 May 2011 at 11:43pm

I think this is somewhat related to this thread [solved] Passing Errors to Custom Form