I'm trying to submit a form but I'm facing a very strange issue.
The form have a field which is an array. Once I submit the form, the website reply that required data are missing. If I manually post the request, the payload is this:
"movimentiC59Nuovo.listaMovimentiItaliani[0].tipoLuogo": "PROVINVCIA",
"movimentiC59Nuovo.listaMovimentiItaliani[0].idObj": "",
"movimentiC59Nuovo.listaMovimentiItaliani[0].timeVar": "",
but if I try to dump $form->getValues()
the response is this:
"movimentiC59Nuovo.listaMovimentiItaliani[0][.tipoLuogo]" => "PROVINVCIA"
"movimentiC59Nuovo.listaMovimentiItaliani[0][.idObj]" => ""
"movimentiC59Nuovo.listaMovimentiItaliani[0][.timeVar]" => ""
as you can see, last part of the name is incapsulated in brackets which I think is the origin of the problem.
I tried to manually create these inputs this way:
$element = $domDocument->createElement('input');
$name = "movimentiC59Nuovo.listaMovimentiItaliani[{$key}]{$input}";
$element->setAttribute('name', $name);
$element->setAttribute('value', $movimento[$input]);
$el = new InputFormField($element);
$form->set($el);
but even if dumping $el
show correct name, once I set()
that as form element, the format return the original.
I figured out that one of the solution might be to create an array and manually POST that, but how should be done that? Its not clean how I should set the POST parameters with Goutte Client. I'm initializing it this way:
$client = new Client();
$jar = new GuzzleHttpCookieCookieJar();
$guzzle = new GuzzleHttpClient([
'timeout' => $timeout,
'cookies' => $jar,
]);
$client->setClient($guzzle);
$client->request('POST', $url, [
"movimentiC59Nuovo.listaMovimentiItaliani[0].tipoLuogo" => "PROVINVCIA",
"movimentiC59Nuovo.listaMovimentiItaliani[0].idObj" => "",
"movimentiC59Nuovo.listaMovimentiItaliani[0].timeVar" => "",
]);
UPDATE: I tested a manual POST instead of $client->submit($form)
and seems to work correctly. I don't know if this could be considered a "bug".