Integrated icon indicating copy to clipboard operation
Integrated copied to clipboard

Problems with input arrays in form

Open cbojer opened this issue 10 years ago • 6 comments

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');

cbojer avatar Mar 30 '15 15:03 cbojer

Can I see the HTML for this?

We can get it fixed.

JeffreyWay avatar Mar 30 '15 17:03 JeffreyWay

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!

cbojer avatar Mar 30 '15 18:03 cbojer

same here..would be great to handle sub arrays :+1:

hardevine avatar Apr 04 '15 14:04 hardevine

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!

nivv avatar Apr 12 '15 14:04 nivv

I have the same issue when I want to submit a form with multiple checkboxes. Does anyone have a solution for this?

loshmis avatar Jun 13 '15 13:06 loshmis

@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.

sadhakbj avatar Sep 21 '15 09:09 sadhakbj