I want to add two field "Name" and "FirstName" in the FosUser Registration Form, but it doesn't work. Here is what I do :
CulturalStore/UserBundle/Ressources/config/services.yml :
services:
cultural_store_user.registration.form.type:
class: CulturalStore\UserBundle\Form\Type\RegistrationFormType
arguments: [%cultural_store_user.model.user.class%]
tags:
- { name: form.type, alias: cultural_store_user_registration }
CulturalStore/UserBundle/Form/Type/RegistrationFormType :
<?php
namespace CulturalStore\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);
// add your custom field
$builder->add('name');
$builder->add('firstname');
}
public function getName()
{
return 'cultural_store_user_registration';
}
public function getFirstName()
{
return 'cultural_store_user_registration';
}
}
CulturalStore/UserBundle/Entity/User.php, I add :
/**
* @ORM\Column(type="string", length=255)
*
* @Assert\NotBlank(message="Entrez votre prénom.", groups={"Registration", "Profile"})
* @Assert\Length(
* min=3,
* max="255",
* minMessage="Prénom trop court.",
* maxMessage="Prénom trop long.",
* groups={"Registration", "Profile"}
* )
*/
protected $firstname;
/**
* @ORM\Column(type="string", length=255)
*
* @Assert\NotBlank(message="Entrez votre nom.", groups={"Registration", "Profile"})
* @Assert\Length(
* min=3,
* max="255",
* minMessage="Nom trop court.",
* maxMessage="Nom trop long.",
* groups={"Registration", "Profile"}
* )
*/
protected $name;
In app/config.yml I have :
registration:
confirmation:
from_email:
address: "[email protected]"
sender_name: "noreply - CulturalStore"
enabled: true
template: CulturalStoreUserBundle:Registration:email.txt.twig
form:
type: cultural_store_user_registration
But I have this error :
ParameterNotFoundException: The service "cultural_store_user.registration.form.type" has a dependency on a non-existent parameter "cultural_store_user.model.user.class".