php - How to add a registration form another field Symfony 2.7 in FOSUserBundle -
how add field on registration form ? so:
\\src\userbundle\form\type\registrationformtype.php <?php namespace userbundle\form\type; //use symfony\component\form\abstracttype; use symfony\component\form\formbuilderinterface; use fos\userbundle\form\type\registrationformtype basetype; class registrationformtype extends basetype { public function buildform(formbuilderinterface $builder, array $options) { parent::buildform($builder, $options); $builder->add('realname'); } public function getparent() { return 'fos_user_registration'; } public function getname() { return 'app_user_registration'; } } \\src\userbundle\resources\config services: app_user.registration.form.type: class: userbundle\form\type\registrationformtype arguments: [%fos_user.model.user.class%] tags: - { name: form.type, alias: app_user_registration } \\src\userbundle\entity\user.php namespace userbundle\entity; use fos\userbundle\model\user baseuser; use doctrine\orm\mapping orm; use symfony\component\validator\constraints assert; /** * @orm\entity * @orm\table(name="web_user") */ class user extends baseuser { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") */ protected $id; /** * @orm\column(type="string", length=255) * * @assert\notblank(message="please enter name.", groups={"registration", "profile"}) * @assert\length( * min=3, * max=255, * minmessage="the name short.", * maxmessage="the name long.", * groups={"registration", "profile"} * ) */ protected $realname; /** * id * * @return integer */ public function getid() { return $this->id; } /** * set realname * * @param string $realname * @return user */ public function setrealname($realname) { $this->realname = $realname; return $this; } /** * realname * * @return string */ public function getrealname() { return $this->realname; } } \\src\userbundle\resources\config\services.yml services: app_user.registration.form.type: class: userbundle\form\type\registrationformtype arguments: [%fos_user.model.user.class%] tags: - { name: form.type, alias: app_user_registration }
i can not understand missing result mistake: not load type "app_user_registration" me please!!! think service not find
i had same problem. (i found post googling error both had) have started learning , toying symfony, please take grain of salt.
try in config.yml :
- delete service wrote ,
- replace with:
fos_user: db_driver: orm firewall_name: main user_class: userbundle\entity\user registration: form: type: app_user_registration
Comments
Post a Comment