symfony - No default option is configured for constraint -


i writing own constraint (silly simple) following documentation symfony 2. after run have error:

no default option configured constraint cgboard\signupbundle\validator\constraints\passwordnotmatching 

i saw in post in stackoverflow solution using service, i'm not sure if solution best, in documentation doesn't appear service regarding simple example.

debugging little saw buildform() method never called. why?

my validation.yml

cgboard\signupbundle\entity\signupdata:   properties:     email:       - notblank: ~     nickname:       - notblank: ~     password:       - notblank: ~     password_repeat:       - notblank: ~       - cgboard\signupbundle\validator\constraints\passwordnotmatching: ~; 

my validator:

<?php namespace cgboard\signupbundle\validator\constraints;  use symfony\component\validator\constraint; use symfony\component\validator\constraintvalidator;  class passwordnotmatchingvalidator extends constraintvalidator {     public function validate($dataform, constraint $constraint)     {         return false;     } }  

my constraint:

<?php namespace cgboard\signupbundle\validator\constraints;  use symfony\component\validator\constraint;  /**  * @annotation  */ class passwordnotmatching  extends constraint {     public $message = 'the password doesnt match';  } 

my controller one:

<?php namespace cgboard\signupbundle\controller\frontend;  use     symfony\component\httpfoundation\request; use     symfony\bundle\frameworkbundle\controller\controller; use     cgboard\signupbundle\entity\user;   class signupcontroller extends controller {     public $signupdata;      public function indexaction(request $request)     {         $signupdata = $this->getsignupdata();         $signupform = $this->getsignupform();         $form       = $this->createform($signupform, $signupdata);          if($request->getmethod() === 'post') {             $form->bind($request);             if($form->isvalid()) {                 $this->save($signupdata);             }         }          return $this->render(                                 'cgboardsignupbundle:frontend:signup.html.twig',                                 array('form'=>$form->createview())         );     }      public function save(\cgboard\signupbundle\entity\signupdata $signupdata)     {         //      }      public function getsignupdata()     {         return new \cgboard\signupbundle\entity\signupdata();     }      public function getsignupform()     {         return new \cgboard\signupbundle\forms\frontend\signupform();       }  }  

my form is:

<?php namespace cgboard\signupbundle\forms\frontend;  use symfony\component\form\abstracttype; use symfony\component\form\formbuilderinterface;   class signupform extends abstracttype {     public function buildform(formbuilderinterface $builder, array $options)     {         die('im here');                        // never called, why??         $builder->add('email');         $builder->add('nickname');         $builder->add('password');         $builder->add('password_repeat');     }      public function getname()     {         return 'signup_form';     } }  

i debugging , saw method buildform() not called ever. why??

for see thread, , uses xml instead of yaml, possible solution same error message:

this not work:

<getter property="fieldname">     <constraint name="test\testbundle\validator\constraints\test">     </constraint> </getter> 

but work:

<getter property="fieldname">     <constraint name="test\testbundle\validator\constraints\test" /> </getter> 

Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -