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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

DBField: Is it possible to get access to the owner DataObject?


Go to End


830 Views

Avatar
Jare

Community Member, 39 Posts

4 May 2017 at 11:14pm

Hi,

this question may have a simple solution, but unfortunately I was not able to solve it by looking at the source code of DBField.

I have a custom DBField, actually inherited from Text, so let's define it for example like this:

class CustomField extends Text
{
    // ...
    public function getValue()
    {
        //Some custom logic to retrieve the value
    }
    // ...
}

Is there any way for me to find out which DataObject owns this particular field? I would need this information in the getValue() method. Something like $this->owner like we are able to use in Extensions or something different?

Thanks! :)