jonathangeiger / kohana-jelly

See the link below for the most up-to-date code
https://github.com/creatoro/jelly
MIT License
146 stars 34 forks source link

How about a $model->revert() method? #149

Closed leth closed 14 years ago

leth commented 14 years ago

How about a method to revert unsaved changes to a model (or field)? I couldn't see one at first glance.

I'm willing to submit a patch for this, if you'd like it added :)

banks commented 14 years ago

Not sure how generally useful this would be. Can you give some use cases?

It is trivial to code but it is better to leave out stuff that won't really be used.

leth commented 14 years ago

Off the top of my head:

The reason I wanted to revert was that the particular form I was showing changed depending on the value of one of the fields, so I wanted to revert back to the old data so the same form would be shown again (overriding the field values directly from $_POST).

banks commented 14 years ago

Hmm. I can see how it would be great in that particular case but that seems a bit of an edge case to me. I guess for now we probably won't put it in as it just won't be used by many people.

leth commented 14 years ago

Sure.

Mostly I just thought it a bit weird at the time that you'd have a clear() method, but no revert() method.

banks commented 14 years ago

I think (but am not sure) clear() is used when iterating through collections since we actually reuse an instance and clone as it is far quicker.

jonathangeiger commented 14 years ago

Adding revert() method. Closed by 49f2937adaec5d1f0bba1ea0ab6ab22d7f84fc48. Thanks leth!