3069 Posts in 868 Topics by 650 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 363 Views |
-
Get Relation on data durung onBeforeWrite (first time) [SOLVED]

2 May 2012 at 1:32pm
I have a dataobject in which I need relation data for a function on the first onBeforeWrite. The relation is set with DropdownField populated with a toDropdownMap in the CMS. In theory I should be able pull the ID from that form element but I'm not sure how its passed to the onBeforeWrite function. Calling $this->RelatedDataObejct doesn't work because that relation isn't set yet. And I can't get the form Value with $this->getField();
I could call the function I need in onAfterWrite and only fire it if the value I'm creating is null and putting another write function in it but that just seems like a recipe for disaster with potential write loops
Any ideas?
-
Re: Get Relation on data durung onBeforeWrite (first time) [SOLVED]

2 May 2012 at 7:56pm
If it is a has_one then $this->RelationNameID should work
-
Re: Get Relation on data durung onBeforeWrite (first time) [SOLVED]

3 May 2012 at 12:56am
The relation is still null at onBeforeWrite the first time. It doesn't get created until the actual write. I'm talking about the initial creation of the record
-
Re: Get Relation on data durung onBeforeWrite (first time) [SOLVED]

3 May 2012 at 12:59am
can you do a var_dump of $this and check for anything that matches the relationship?
we are talking a has_one relationship right?
-
Re: Get Relation on data durung onBeforeWrite (first time) [SOLVED]

3 May 2012 at 12:49pm
I got fixed, the DataObject in question was an extension of DataObjectAsPage so I wrapped the functions in my onBeforeWrite in a if($this->ID !=0). I'll post that it needs to be documented
| 363 Views | ||
|
Page:
1
|
Go to Top |


