的我嘗試在我的RegistrationFormType
獲取對象會話,但我得到這個錯誤:Warning: Missing argument 2 for Meet\MembreBundle\Form\Type\RegistrationFormType::__construct()
Symfony2中獲取會話中RegistrationFormType FosUserBundle
我RegistrationFormType:
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 }
這不是會話的問題,它是缺少'%fos_user.model.user.class%'參數的問題 – 2012-07-26 13:33:12
我怎樣才能獲得我的表單中的會話對象? – user1364017 2012-07-26 13:37:00