我尝试在我的对象会话中获取对象会话,RegistrationFormType
但出现此错误:Warning: Missing argument 2 for Meet\MembreBundle\Form\Type\RegistrationFormType::__construct()
我的注册表格类型:
namespace Meet\MembreBundle\Form\Type;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
class RegistrationFormType extends BaseType
{
private $session;
public function __construct($session, $class)
{
$this->session = $session;
parent::__construct($class);
}
public function buildForm(FormBuilder $builder, array $options)
{
parent::buildForm($builder, $options);
$locale = $this->session->getLocale();
var_dump($locale);
}
public function getName()
{
return 'meet_user_registration';
}
}
我的 config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
# Permet de renseigner la nouvelle entity utilisateur
user_class: Meet\MembreBundle\Entity\Membre
registration:
form:
type: meet_user_registration
services:
meet_user_registration:
class: Meet\MembreBundle\Form\Type\RegistrationFormType
arguments: [@session, %fos_user.model.user.class%]
tags:
- { name: form.type, alias: my_user_registration }