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

Change in model should be reflected in form #82

Closed
joshpfosi opened this issue Jan 21, 2015 · 8 comments
Closed

Change in model should be reflected in form #82

joshpfosi opened this issue Jan 21, 2015 · 8 comments

Comments

@joshpfosi
Copy link

Hi, I am using ember-forms for a job creation form. The basic logic is that the user fills it out, submits the form, and upon successful return on the backend, the model (for the page) gets reset to a blank model (controller.set('model', self.store.createRecrd('job'))). This works fine with traditional forms but ember-forms only resets the model, not the form component elements.

I feel like this is a common use case so am I missing an idiomatic way to do this?

@joshpfosi
Copy link
Author

Is this still being maintained?

@neverfox
Copy link

I have no idea if it's being maintained or not, but these form libraries have always seemed like overkill to me. I curious what benefits you were getting over just binding to form HTML.

@asaf
Copy link
Contributor

asaf commented Feb 24, 2015

@joshpfosi It is maintained (sometimes under high pressure and can't find the time to answer all questions), it should work, we do this all the time, can you please provide a jsbin example or some full project github url I'll try to fix it for you,

@neverfox If you like code repetition and blowing up your templates for styles, validations, layout , etc then go a head and write in plain html :)

@neverfox
Copy link

@asaf That probably came off snarkier than I intended. Your points are well-taken, but, as you alluded to, it is ultimately a matter of preference along the spectrum of encapsulation vs. transparency (or "just enough magic and no more"). In certain cases (forms being one of them), I often find it easier to maintain and refactor my code when I'm working with the "basics" and doing vanilla Ember binding to HTML attributes, and repetition is often solved through the clever use of IDE snippets. Sometimes, it's just not worth getting in to bed with a third-party component that might ultimately limit flexibility, and sometimes it's well worth it. Of course, a flexible component is the best of both worlds. Cheers.

@joshpfosi
Copy link
Author

@asaf Here's a rough jsbin

http://jsbin.com/xapigunesi/1/edit

I can't get your library to import which is strange (I've looked at other jsbin's featuring ember forms with the same result). Also, ember data seems to not be loading. I don't expect you to debug this, but I don't have time to get it working right this minute. Hopefully, you can see the gist of what I'm trying to do!

The meat of it is in the save method of the controller which, on success, should clear the form by clearing its associated model. This works as far as ember data is concerned, but the component's values do not update.

@joshpfosi
Copy link
Author

@asaf I actually found an issue that speaks to the identical problem from summer last year (#23)

@koryteg
Copy link

koryteg commented Mar 16, 2015

plus one here. it might be an ember-1.10 bug that got introduced but if the form doesnt have to re render the model doesn't change.

@asaf
Copy link
Contributor

asaf commented May 11, 2015

PR #92 merged.

@asaf asaf closed this as completed May 11, 2015
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

4 participants