php - Symfony forms from entity with additional fields -


as know create form using form type: $form = $this->createform(new registrationtype(), $user);

and here form type:

class registrationtype extends abstracttype {     public function buildform(formbuilderinterface $builder, array $options)     {         $builder->add('name', 'text');         $builder->add('email', 'email');          $builder->add('terms', 'checkbox', array(             'mapped' => false         ));     }      public function setdefaultoptions(optionsresolverinterface $resolver)     {         $resolver->setdefaults(array(             'data_class' => 'app\usersbundle\entity\user'         ));     }      public function getname()     {         return 'user_registration';     }  } 

so add field term , don't map entity. way validate field? sure can if ($form->get('terms')->getdata()) in controller want use 1 function $form->isvalid() validate fields (mapped , don't mapped)? may validate hooks or events exists?

it's covered in the adding validation section of forms chapter.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -