frontile
frontile copied to clipboard
ChangesetForm: @onSubmit data arg is undefined
I'm trying to use the @onSubmit function for changeset forms.
The data
arg is always undefined.
result
seems to just be the changeset that was saved.
I see a data
property in the changeset docs, but for me it's undefined even though the changeset saved successfully.
https://github.com/poteto/ember-changeset#data
Maybe simply returning the changeset will be the most flexible for users of this API?
As a workaround for this (I need the id for the newly created model object) I'm creating the changeset on the component:
changeset = new Changeset(
this.args.model,
lookupValidator(this.validations),
this.validations
);
and in the function I used for the @onSubmit
in the ChangesetForm I can get the id from the component's changeset :
@action
handleSubmit(data, event) {
this.router.transitionTo(
'route.for.redirection',
this.changeset.get('id')
);
}
But yes, I agree it's better if the @onSubmit
function returns the changeset on the data
attribute