Problems with input arrays in form
Hello Jeffrey,
I've run into trouble on a current test, as I'm trying to test a form that has input arrays. The problem is the fact that the input data is formatted differently when submitting the form via the test, than when submitting the form via a browser.
Example: Output from browser(when i dump the request):
array:3 [
"facilities" => array:5 [▼
"FacilityOne" => "1"
"FacilityTwo" => "2"
]
]
Output when submitting the form from the test:
`array:4 [
"facilities[FacilityOne]" => "1"
"facilities[FacilityTwo]" => "2"
]
Due to this, I can no longer access the input in my controller by
$request->get('facilities');
Can I see the HTML for this?
We can get it fixed.
Sure, this is an example of it:
<form action="/post-url" method="POST">
<input type="text" name="facilities[FacilityOne]" />
<input type="text" name="facilities[FacilityTwo]" />
<input type="submit" value="Save" />
</form>
Would be great!
same here..would be great to handle sub arrays :+1:
Having the same issue with multiple select-boxes as well.
<select id="input-tags" name="tags[]" multiple>
<option value="1">Tag 1</option>
<option value="2">Tag 2</option>
</select>
@hardevine solution works though!
I have the same issue when I want to submit a form with multiple checkboxes. Does anyone have a solution for this?
@nivv sir , i am currently facing the same problem. I dont know how to solve it. my form looks like this: `
. . ` How can i select multiple things ?$this->select('resource[] , ['Coal' , 'kjkjk'});
is all what i know but i am not able to solve it.