我正在使用FOSUserBundle並覆蓋了RegistrationController
。當表格提交併且有效時,我想要獲取用戶在註冊表中輸入的電子郵件地址。如何從FOSUserBundle註冊表單獲取表單數據?
但我看不出有什麼辦法得到它。由於從Symfony2 forms documentation拍攝,你可以得到表單數據是這樣的:
$this->get('request')->request->get('name');
但RegistrationController
不知道get()
方法(因爲它不是從Symfony2的控制器實體繼承)。所以我可以這樣做:
// Note the ...->container->...
$this->container->get('request')->request->get('name');
但是,這返回NULL
。現在我試着從$form
得到它。
// Does contain a lot of stuff, but not the entered email address
$form->get('email');
// Does also contain a lot of stuff, but not the desired content
$request->get('email');
$request->request('email');
// Throws error message: No method getData()
$request->getData();
任何想法?
做到了!謝謝! –