brainfoolong/form-data-json

Array is expected

Closed this issue ยท 4 comments

Describe the bug
I expect array for multiple values, but hash is returned

To Reproduce

<form>
	<input name = "docn">
	<input name = "docdate">

	<input name = "client[name]">
	<input name = "client[edrpou]">

	<input name = "client[phone][]">
	<input name = "client[phone][]">
	<input name = "client[phone][]">


	<input name = "client[email][]">
	<input name = "client[email][]">

	<select name="client[status][]" id="cars" multiple>
	  <option value="volvo">Volvo</option>
	  <option value="saab">Saab</option>
	  <option value="opel">Opel</option>
	  <option value="audi">Audi</option>
	</select>

	<input type="checkbox" name="scales[]" checked value="77">
	<input type="checkbox" name="scales[]">
</form>
FormDataJson.fillFormFromJsonValues($("form")[0], 
  {docn : 'asdf', docdate: 'addd', client: { name: 'asdf DDD', phone: [ 'zzzz', 'dd' ] } }, 
  new FormDataJsonOptions({ unsetAllInputsOnFill: true }) 
)

image

Thanks for the bug report. I can confirm that there is currently no array return for numeric indexed objects, that should obviously be an array. I will fix this.

Ah, this may take a while longer as expected to fix this. It's easy to fix them in the first place, but it does not incorparate with the counterpart (fillFromJson and toJson) well, because this internal process does handle some things very special when a real array is passed. I have to refactor that a bit and do some more tests with this.

This error should be fixed in the new pre-release.

fixed