forms - Could not load type "sonata_user_registration" -
when try override registration form in sonatauserbundle got error : "could not load type "sonata_user_registration"".i searched solution of problem of them doesn't me. override template now, need override registration form(add age field), added few code in
//app/application/sonata/userbundle/entity/user.php /** * @orm\column(type="string", length=255) * * @assert\notblank(message="please enter name.", groups={"registration", "profile"}) */ protected $age; public function getage() { return $this->age; } public function setage($age) { $this->a=$age; }
but if run php app/console doctrine:schema:update --force told nothing update registrationformtype:
//app/application/sonata/userbundle/form/type/registrationformtype.php namespace application\sonata\userbundle\form\type; 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('age'); } public function getname() { return 'sonata_user_registration'; } public function getparent() { return 'fos_user_registration'; } }
my services.yml:
//app/application/sonata/userbundle/resources/config/services.yml services: sonata_user.registration.form.type: class: application\sonata\userbundle\form\type\registrationformtype arguments: [ "%fos_user.model.user.class%"] tags: - { name: form.type, alias: sonata_user_registration }
config.yml:
fos_user: user_class: application\sonata\userbundle\entity\user group: group_class: application\sonata\userbundle\entity\group group_manager: sonata.user.orm.group_manager service: user_manager: sonata.user.orm.user_manager registration: form: type: sonata_user_registration sonata_user: security_acl: true manager_type: orm
and dependencyinjection in //app/application/sonata/userbundle/dependencyinjection
namespace application\sonata\userbundle\dependencyinjection; use symfony\component\httpkernel\dependencyinjection\extension; use symfony\component\dependencyinjection\containerbuilder; use symfony\component\dependencyinjection\loader\yamlfileloader; use symfony\component\config\filelocator; class sonatauserextension extends extension { public function load(array $configs, containerbuilder $container) { $loader = new yamlfileloader($container, new filelocator(__dir__.'/../resources/config')); $loader->load('services.yml'); } }
Comments
Post a Comment