indexiatech / ember-forms

Smart, Intuitive forms for Ember.js styled with Bootstrap, Multi layouts and Validation support.
http://indexiatech.github.io/ember-forms
Apache License 2.0
218 stars 45 forks source link

Change in model should be reflected in form #82

Closed joshpfosi closed 9 years ago

joshpfosi commented 9 years ago

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 commented 9 years ago

Is this still being maintained?

neverfox commented 9 years ago

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 commented 9 years ago

@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 commented 9 years ago

@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 commented 9 years ago

@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 commented 9 years ago

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

koryteg commented 9 years ago

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 commented 9 years ago

PR #92 merged.