Skip to content
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

ChangesetForm: @onSubmit data arg is undefined #218

Open
mcfiredrill opened this issue Aug 5, 2022 · 1 comment
Open

ChangesetForm: @onSubmit data arg is undefined #218

mcfiredrill opened this issue Aug 5, 2022 · 1 comment

Comments

@mcfiredrill
Copy link

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?

@chsanch
Copy link

chsanch commented Oct 22, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants