Symfony Form Model @Unique on new Email field -


Good evening,

I have added a form to replace a user's email:

= & gt; 'Startup', 'map' = & gt; False, 'attr' = & gt; Array ('just reading'> & gt; true; 'value' => $ this-> user- & gt; getEmail ())) '& quot; Array ('translate_domain' = & gt; 'startup'), & quot; New_email ',' duplicated ', array (' type '= & gt;' email ',' option '= & gt; array (' label '= & gt;' profile.changePassOrEmail.newEmail '),' seconds_points' = & Array ('label' = & gt; 'profile.changePassOrEmail.newEmail2'), 'invalid_mail' => profile.changeEmail.mismatch ',))

' 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

Popular posts from this blog

winforms - C# Form - Property Change -

java - Algorithm negotiation fail SSH in Jenkins -

java - Messages from .properties file do not display UTF-8 characters -