forms - Symfony2 setDefaultOptions(OptionsResolverInterface $resolver) -


i quite new in symfony2. trying develop website can register/login. trying make register form thows exception regarding setdefaultoptions(optionsresolverinterface $resolver) method.

registertype.php:

<?php  namespace myappbundle\form\type;  use symfony\component\form\abstracttype; use symfony\component\form\formbuilderinterface; use symfony\component\form\extension\core\type\emailtype; use symfony\component\form\extension\core\type\texttype; use symfony\component\form\extension\core\type\repeatedtype; use symfony\component\form\extension\core\type\passwordtype; use symfony\component\form\extension\core\type\numbertype; use symfony\component\optionsresolver\optionsresolver; use symfony\component\optionsresolver\optionsresolverinterface;  class registertype extends abstracttype {     public function buildform(formbuilderinterface $builder, array $options){         $builder             ->add('name', texttype::class, array(                     'label' => 'your name',                     'label_attr' => array(                         'attr' => array(                             'class' => 'control-label'                         )                     ),                     'attr' => array(                         'class' => 'form-control'                     )                 ))             ->add('email', emailtype::class, array(                     'label' => 'your email',                     'label_attr' => array(                         'attr' => array(                             'class' => 'control-label'                         )                     ),                     'attr' => array(                         'class' => 'form-control'                     )                 ))             ->add('password',repeatedtype::class, array(                     'type' => passwordtype::class, array(                         'first_options'  => array(                             'label' => 'your password', array(                                 'label_attr' => array(                                     'attr' =>array(                                         'class'=> 'control-label'                                     )                                 )                             ),                             'attr' => array(                                 'class' => 'form-control'                             )                         ),                         'second_options' => array(                             'label' => 'repeat password', array(                                 'label_attr' => array(                                     'attr' =>array(                                         'class'=> 'control-label'                                     )                                 )                             ),                             'attr' => array(                                 'class' => 'form-control'                             )                         )                   )))             ->add('tel', numbertype::class, array(                     'label' => 'your telephone number',                     'label_attr' => array(                         'attr' => array(                             'class' => 'control-label'                         )                     ),                     'attr' => array(                         'class' => 'form-control'                     )                 ))             ->add('register', 'submit', array(                     'attr' => array(                         'class' => 'btn btn-default'                     )                 ));     }      /**      * @param optionsresolverinterface $resolver      */     public function setdefaultoptions(optionsresolverinterface $resolver)     {         $resolver->setdefaults(['data_class' => 'myappbundle\entity\users']);     }      public function getname(){         return 'register';     } } 

registercontroler.php

<?php  namespace myappbundle\controller;  use myappbundle\form\type\registertype; use symfony\bundle\frameworkbundle\controller\controller; use myappbundle\entity\users; use symfony\component\httpfoundation\request;  class registercontroller extends controller {     public function indexaction(request $request)     {         $user = new users();          $form = $this->createform(new registertype($user), array(                 'action' => $this->generateurl('myapp_register'),                 'method' => 'post'             ));           if($form->issubmitted() && $form->isvalid()){             $em = $this->getdoctrine()->getmanager();             $em->persist($user);             $em->flush();              return $this->redirect($this->generateurl('myapp_homepage'));         }          return $this->render('myappbundle:default:register.html.twig', array('form' => $form->createview(),));     } } 

the error is:

critical - uncaught php exception symfony\component\optionsresolver\exception\undefinedoptionsexception: "the option "0" not exist. defined options are: "action", "allow_extra_fields", "attr", "auto_initialize", "block_name", "by_reference", "cascade_validation", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_provider", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "first_name", "first_options", "inherit_data", "intention", "invalid_message", "invalid_message_parameters", "label", "label_attr", "label_format", "mapped", "max_length", "method", "options", "pattern", "post_max_size_message", "property_path", "read_only", "required", "second_name", "second_options", "translation_domain", "trim", "type", "validation_groups", "virtual"." @ c:\users\vicky\documents\my documents\projects\vf-housing_symfony\vendor\symfony\symfony\src\symfony\component\optionsresolver\optionsresolver.php line 760  

can please me?

i use configureoptions method map entity form. try this:

public function configureoptions(optionsresolver $resolver) {     $resolver->setdefaults(         array(             'data_class' => 'myappbundle\entity\users',         )     ); } 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo