When i try override the registration form in SonataUserBundle i got this error : "Could not load type "sonata_user_registration"".I searched the solution of this problem but any of them doesn't help me. I successfully override template but now, I need override registration form(add age field), so I added few code in
//app/Application/Sonata/UserBundle/Entity/User.php
/**
* @ORM\Column(type="string", length=255)
*
* @Assert\NotBlank(message="Please enter your name.", groups={"Registration", "Profile"})
*/
protected $age;
public function getAge()
{
return $this->age;
}
public function setAge($age)
{
$this->a=$age;
}
But if i run php app/console doctrine:schema:update --force it told nothing to update My 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 as 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
Aucun commentaire:
Enregistrer un commentaire