3093 Posts in 875 Topics by 654 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 328 Views |
-
write() - Method on Field of Subclass of $has_many - DataObject

17 December 2011 at 5:41am
Hello,
i got that following setup:
Page-Class width 2 $has_many relations, to: lets say "Customer"- and "CustomerPremium"- DataObjects.
My CustomerPremuim - Class is a direct Subclass of Customer.Now i want an db-write - operation (update a Field) on each related CustomerPremium DataObject in that onAfterWrite() - Method on the Page-Class.
If i target the Parent-Class "Customer" with "$this->Customer()" the write() Method works, but not on the Subclass.
Even since the Subclass has its own $has_many relation in Page.Any Idea why is that?
if i print out the result of the iteration i get my regular DataObjects in any case. So i'm wondering that i cant write to it just because
its an Subclass.my code is:
class Page extends .... {$has_many {
"Customers" => "Customer",
"CustomersPremium" => "CustomerPremium"
}function onAfterWrite(){
foreach($this->CustomerPremium() as $i) {
$i->Format = "482 x 288";
$i->write();
}parent::onAfterWrite();
.....
Thanks!
-
Re: write() - Method on Field of Subclass of $has_many - DataObject

19 December 2011 at 3:58am
Ok, my Problem seems to be solved.
After min. 5 Hours walking down the wrong way I figured out that my Eventhandler onAfterWrite has to be changed in onBeforeWrite...;-s
| 328 Views | ||
|
Page:
1
|
Go to Top |

