How can I remove an individual parameter from a Symfony2 request object

Viewed 17814

I have the following request object and would like to remove 'email_suffix' from a controller before binding to a form. Is this possible?

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)

I have tried $request->request->remove("registration[email_suffix]");

I can do $request->request->remove("registration") - this works.

For now, I am doing this:

$requestReg = $request->request->get('registration');
$requestReg['email'] = $requestReg['email'].'@'.$requestReg['email_suffix'];
unset($requestReg['email_suffix']);
$request->request->set('registration',$requestReg);
2 Answers
Related