-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
I'm unable to save a model due to ember-cli-form-data extracting the incorrect root.
Model:
export default Model.extend({
title: attr(),
image: attr('file'),
description: attr(),
thumbnail: attr(),
createdAt: attr('date')
});
Controller:
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
submit() {
const model = this.store.createRecord('image', {
title: this.get('title'),
description: this.get('description')
});
const image = document.getElementById('image').files[0];
model.set('image', image);
model.save();
}
}
});
This is the resulting payload:
------WebKitFormBoundarydHjcL7c0dAoCTjNp
Content-Disposition: form-data; name="title[0]"t
------WebKitFormBoundarydHjcL7c0dAoCTjNp
Content-Disposition: form-data; name="title[1]"e
------WebKitFormBoundarydHjcL7c0dAoCTjNp
Content-Disposition: form-data; name="title[2]"s
------WebKitFormBoundarydHjcL7c0dAoCTjNp
Content-Disposition: form-data; name="title[3]"t
------WebKitFormBoundarydHjcL7c0dAoCTjNp--
Working through the breakpoints I see this in the ember-cli-form-data adapter:
_getFormData: function _getFormData(data) {
// data is {title: 'test', description: 'test', image: File}
var formData = new FormData();
var root = Object.keys(data)[0]; // root is 'title'
Metadata
Metadata
Assignees
Labels
No labels