我有以下请求对象,并希望在绑定到表单之前从控制器中删除“email_suffix”。这可能吗?
public 'request' =>
object(Symfony\Component\HttpFoundation\ParameterBag)[8]
protected 'parameters' =>
array
'registration' =>
array
'email' => string 's' (length=1)
'email_suffix' => string 'y.com' (length=5)
'password' => string '1234' (length=4)
'_token' => string '967d99ba9f955aa67eb9eb004bd331151d816d06' (length=40)
'product_id' => string '2' (length=1)
'product_description' => string '12 month membership' (length=19)
'product_price' => string '6.99' (length=4)
我试过了 $request->request->remove("registration[email_suffix]");
我可以做 $request->request->remove("registration") - 这行得通。
现在,我正在这样做:
$requestReg = $request->request->get('registration');
$requestReg['email'] = $requestReg['email'].'@'.$requestReg['email_suffix'];
unset($requestReg['email_suffix']);
$request->request->set('registration',$requestReg);