Symfony Form Model @Unique on new Email field -
Good evening,
I have added a form to replace a user's email:
' new_email ' I created a form model class as the following:
cl donkey ChangeEmail {/ ** * @War String * @ Esparta \ NoteBank () * @Assert \ Email () * / Public $ new_mail; }
The following is the procedure to create and process my Controller form:
* / Public Function Change Emailmail (Request $ Request) {$ user = $ This- & gt; Container- & gt; Get ('security.context') - & gt; GetToken () - & gt; GetUser (); If (! Is_object ($ user) || $$ Example of user user interface) {new accessedexexation ('This user does not have access to this section.'); } $ Form_email = $ this- & gt; CreateForm (new ChangeEmailFormType ($ user)); $ Form_email- & gt; SetData (new ChangeEmail ()); $ Form_email- & gt; HandleRequest ($ request); If ($ form_email- & gt; isValid ()) {} other {} $ $ - return - ('UserBundle: ChangeEmail: changeEmail.html.twig', array ('form_email' = & gt; $ form_email-> ; CreateView ())); }
All this works well, but I have a problem with the "ChangeEmail" class. I do not know how to add an "extra" comment to the $ new_email field. How can I check or even make a custom annotation to check whether the email already exists on my useable? In the registration form, FosUserBundle handles.
Regards and Thanks.
Solution: I have written my own validator and have tied it in the new_email field.
Comments
Post a Comment