How to add a field on the registration form ? I do 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 as 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 as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as 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 your name.", groups={"Registration", "Profile"})
* @Assert\Length(
* min=3,
* max=255,
* minMessage="The name is too short.",
* maxMessage="The name is too long.",
* groups={"Registration", "Profile"}
* )
*/
protected $realname;
/**
* Get 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;
}
/**
* Get 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 what is missing The result is a mistake: Could not load type "app_user_registration" Help me please!!! I think that the service does not find