Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.


Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w


Go to End

12 Posts   5077 Views


9 September 2008 at 5:50am 4085 Posts

Is there such a thing? Best I can do is overload the write() function like so..

public function write() {
// do some stuff

The problem is, the "do some stuff" gets executed 4 times. Any idea why write() gets called so many times? Once for each relation, maybe? And what can I do about this?


9 September 2008 at 12:20pm Forum Moderator, 5511 Posts

There should be an onAfterWrite method you can use. Well theres a onAfterWrite() in trunk at least.


9 September 2008 at 12:44pm 4085 Posts

Cool. Any idea why the write() method runs four times on my updates? Does it run once for every related object?

What I'm trying to do is take data that is saved on the object and duplicate some of the record info into another table when the form is saved. The problem is, when the write() method gets executed 4 times, it makes 4 insertions into that table.


9 September 2008 at 12:46pm 4085 Posts

Also, while I have you here... I'm wondering, how do you specify the difference between data that was already saved on the record versus info that the user is saving into it through the form?


doesn't seem to bring different results for me. Should $this->record be populated with the user's form data?


9 September 2008 at 1:23pm Forum Moderator, 5511 Posts

Ive just had alook at onBeforeWrite() and it looks like the current value is stored in $this->Field and the new data in $_POST['Field']. Just tried the same with onAfterWrite and it returned exactly the same - $this->Field contained the old values hmm.


11 September 2008 at 2:24pm Community Member, 712 Posts

I'm experiencing similar problems - onBeforeWrite seems to execute multiple times, onAfterWrite does not appear to execute at all.


11 September 2008 at 2:25pm Community Member, 712 Posts

ah, found this on another post:

//WHATCH OUT: The function onAfterWrite() is only useable when you use the Daily builds, it's not included in the Version 2.2.2
function onAfterWrite()


12 September 2008 at 12:15am 4085 Posts

Interesting. Thanks for that. Did we ever figure out why write() and onBeforeWrite() fire so many times?

Go to Top