php - AutowiringFailedException when overriding FOSUserBundle registration form -


(using symfony 3 on wampserver on windows 10)

i trying extends fosbundle's user form according following instructions https://knpuniversity.com/screencast/fosuserbundle/customize-forms (i chose option "override" skipped "extend" part using getparent())

i get

**autowiringfailedexception** cannot autowire service "app.form.registration": argument "$class" of method "appbundle\form\registrationformtype::__construct()" must have type-hint or given value explicitly. 

some configuration: ..\appbundle\form\registrationformtype.php

<?php  /*  * file part of fosuserbundle package.  *  * (c) friendsofsymfony <http://friendsofsymfony.github.com/>  *  * full copyright , license information, please view license  * file distributed source code.  */  namespace appbundle\form;  use fos\userbundle\util\legacyformhelper; use symfony\component\form\abstracttype; use symfony\component\form\formbuilderinterface; use symfony\component\optionsresolver\optionsresolver;  class registrationformtype extends abstracttype {     /**      * @var string      */     private $class;      /**      * @param string $class user class name      */     public function __construct($class)     {         $this->class = $class;     }      /**      * {@inheritdoc}      */     public function buildform(formbuilderinterface $builder, array $options)     {         $builder             ->add('email', legacyformhelper::gettype('symfony\component\form\extension\core\type\emailtype'), array('label' => 'form.email', 'translation_domain' => 'fosuserbundle'))             ->add('username', null, array('label' => 'form.username', 'translation_domain' => 'fosuserbundle'))             ->add('plainpassword', legacyformhelper::gettype('symfony\component\form\extension\core\type\repeatedtype'), array(                 'type' => legacyformhelper::gettype('symfony\component\form\extension\core\type\passwordtype'),                 'options' => array('translation_domain' => 'fosuserbundle'),                 'first_options' => array('label' => 'form.password'),                 'second_options' => array('label' => 'form.password_confirmation'),                 'invalid_message' => 'fos_user.password.mismatch',             ))             ->add('number')         ;     }      /**      * {@inheritdoc}      */     public function configureoptions(optionsresolver $resolver)     {         $resolver->setdefaults(array(             'data_class' => $this->class,             'csrf_token_id' => 'registration',             // bc sf < 2.8             'intention' => 'registration',         ));     }      // bc sf < 3.0     /**      * {@inheritdoc}      */     public function getname()     {         return $this->getblockprefix();     }      /**      * {@inheritdoc}      */     public function getblockprefix()     {         return 'fos_user_registration';     } } 

custom user class

<?php namespace appbundle\entity; use fos\userbundle\model\user baseuser; use doctrine\orm\mapping orm;  /**  * @orm\entity  * @orm\table(name="`fasuser`") */ class fasuser extends baseuser {     /**          * @orm\id          * @orm\generatedvalue(strategy="auto")          * @orm\column(type="integer")     */     protected $id;      public function getid()     {         return $this->id;     }       /**      * @orm\column(type="string")      */     protected $number;      public function getnumber()     {         return $this->number;     }     public function setnumber(string $number)     {         $this->number = $number;     }  } 

in services.yml:

(...)     app.form.registration:         class: appbundle\form\registrationformtype         tags:             - { name: form.type } 

in config.yml:

(...) fos_user:     (...)     registration:         form:             type: appbundle\form\registrationformtype 

remove __constructor registrationformtype:

and change data_class:

$resolver->setdefaults(array(       ......       'data_class' => 'appbundle\entity\user', //your user entity class       ...... 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -