Symfony set request parameters in array format

Viewed 226

I'm trying to set up my own request which I could send to a method for testing purposes, but I can't seem to find how to format it.

Right now I'm trying to pull array out of the request

$data = $request->request->get('itemData');

It should look like this once I get it:

[ 
    'basic' => [
        'type'   => 1
        'country => 1
    ],
    'information' => [
        'wadding' => 1
    ]
]

I have written it like this:

$request->request->set("itemData[basic][type]", 2);
$request->request->set("itemData[information][wadding]", 0);

But I get null since the key is not itemData but for example itemData[basic][type]

How do I format it in the set command so the request parameters are sent in array form?

1 Answers

Figured it out

$request->request->set("itemData",
    [
    'basic'       => ['type' => 2, 'country' => 1],
    'information' => ['wadding' => 0]
    ]
);
Related