Re: [symfony-users] Re: On $form-save() and knowing if anything has changed

2010-11-22 Thread oscar balladares
Im not an expert, but I would suggest you to implement a getHashCode() method for your objects. What I recall, a hashcode is like a unique number result of a calculation based on the attributes values and types of a class; it is like a check sum. So if you have an updated_at attribute, the old

[symfony-users] Re: On $form-save() and knowing if anything has changed

2010-11-14 Thread LeBurt
@Richtermeister: Good idea, I dumped the serialized objects before and after and they are indeed different, although not in the updated_at field which I'm not using. This is what I got: Before: string(2636) C:8:Supplier:1864:{a:14:{s:3:_id;a:1:{s:2:id;i:8;}

[symfony-users] Re: On $form-save() and knowing if anything has changed

2010-11-14 Thread LeBurt
Well, we can mark this one solved. Daniel's solution seemed simple and elegant but I couldn't really figure it out with my cuurent level of knowledge. Then I read Richtermeister's post again and fathomed that all I'd have to do is add the timestampable behavior on my Doctrine class and then do

Re: [symfony-users] Re: On $form-save() and knowing if anything has changed

2010-11-14 Thread Daniel Lohse
Yes, you can indeed do that — I might have a look at the Timestampable behavior and see what it does, maybe you'll get some more insights into how you can do this some other way but if you can live with your solution then that's also fine. :) Cheers, Daniel Sent from my iPad On Nov 15,

[symfony-users] Re: On $form-save() and knowing if anything has changed

2010-11-14 Thread LeBurt
Well, I suppose I can live with it for the moment. My ideal solution would be like this: $supplier = $form-save(); if ($supplier-isModified()) return 'changes'; else return 'nochange'; but I'm afraid I need more time before I can come up with a solution to this myself. I'm not just learning

[symfony-users] Re: On $form-save() and knowing if anything has changed

2010-11-12 Thread LeBurt
Thanks for the suggestion Gareth. Unfortunately it doesn't work. Since I'm not all that knowledgeable in OOP, I was thinking this might have something to do with the $oldstate and $newstate objects being the same (two references to the same object), that way when you change one the other changes

[symfony-users] Re: On $form-save() and knowing if anything has changed

2010-11-12 Thread Richtermeister
Hey there, your first insight is right, you're holding 2 references to the same object, so it'll always be the same. In your second case I could only imagine that the updated_at field is being updated (maybe). To find out, why don't you look at the serialized strings and see where they differ...

Re: [symfony-users] Re: On $form-save() and knowing if anything has changed

2010-11-12 Thread Daniel Lohse
What do you want to do? Before you save the form (and therefore the object), you can get at the changes like described here: http://groups.google.com/group/symfony-users/browse_thread/thread/be414f79f499f869/a18b2291ba30275c?lnk=gstq=doctrine+isModified#a18b2291ba30275c Just add the