-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
defaultValue should make models dirty #2566
Comments
I agree as well, although maybe there should be a way to override the behavior. For example, if you have a |
I disagree - if you want a default value in the UI, use a controller. For my money, defaultValue should only be used when creating new records. It shouldn't override what we get from the server. |
It is surprising to me that I'm going to close this issue. Feel free to re-open if you disagree. |
What about making the change for 3.0? |
+1 for changing this in 3.0 |
To restate the original request here:
My concern is that the use cases for "create a record with default values and save it" sounds suspiciously like "API actions". For instance, likes on a like button, in which the record itself is barely cared about. Now, it may be that an "API action" should actually be added as a relationship to something else, in which case this was valid, but more often than not I see this in the "discardable local record" situation. And, to go with our "like" example, were this a like there would be a relationship. Ergo, I don't see this feature as useful for anything other than "disregarded API actions", for which the following pattern is better, using the example of
cc @wecc |
Dumping this here after discussion with @runspired, @stefanpenner and @tchak: The current It's possible that the current This definitely needs to go through the RFC process 📝 |
We do serialize |
In the JSBin below, I've got an
App.Book
model with a default value for thetitle
attribute, and a book instance retrieved from the server that has no value for itstitle
attribute:http://emberjs.jsbin.com/xaniheguto/2/edit?html,js,output
The book's title is automatically set via the
defaultValue
option. However, the model isn't marked dirty andmodel.rollback()
doesn't set the title toundefined
. I might be alone here, but I would expect any model that's changed in memory to be marked dirty so I know whether or not it differs from the state on the server, and the fact thatdefaultValue
is an exception to that behavior is a surprise.One use-case might be if you're using Firebase, Dropbox Datastore API, etc as a back-end. You can't write server code to validate your data, so you have to do it on the front-end. In this particular case, you'd have no practical way of knowing that the book's title on the server is actually
null
.The text was updated successfully, but these errors were encountered: