-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FormData append not working for Objects nor Arrays (recursive). #14
Comments
esbanarango
added a commit
to esbanarango/ember-attachable
that referenced
this issue
Apr 28, 2015
@esbanarango hey. yes, it seems it doesn't work. you can issue a PR to fix this. thanks. |
@sol1dus Sure! Already have the solution working locally. Writing the tests now... |
FormData.prototype.appendRecursive = function(data, wrapper) { for(var x in data) { if(typeof data[x] == 'object' || data[x].constructor === Array) { this.appendRecursive(data[x], wrapper + '[' + x + ']'); } else { this.append(wrapper + '[' + x + ']', data[x]); } } } var dataObject = { some_field : 'some_value', some_field2 : { some_field2_1 : 'some_value2_1', some_field2_2 : 'some_value2_2' }, some_field3 : 'some_value3' } var formData = new FormData(); formData.appendRecursive(dataObject, wrapper); // root wrapper is optional // Your should get |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let's say I have an ember model that after being serialized looks like this:
With the current way of appending data to the formData the
product_attributes
attribute will have a value of"[object object]"
. Same happens if I have an array with more than 1 dimension.The text was updated successfully, but these errors were encountered: