elliot-sawyer / silverstripe-linkfield

Adds a Linkfield for gorriecoe/silverstripe-link
BSD 3-Clause "New" or "Revised" License
9 stars 25 forks source link

Error when Extending SiteConfig #7

Closed jrson83 closed 5 years ago

jrson83 commented 5 years ago

I tried to extend the SiteConfig with a linkable field.

https://docs.silverstripe.org/en/4/developer_guides/configuration/siteconfig/#extending-siteconfig

use SilverStripe\ORM\DataExtension;

use SilverStripe\ORM\DataObject;
use SilverStripe\CMS\Model\SiteTree;

use gorriecoe\Link\Models\Link;
use gorriecoe\LinkField\LinkField;

class CustomSiteConfig extends DataExtension 
{
    private static $has_one = [
        'LinkShop' => Link::class
    ];
public function updateCMSFields(FieldList $fields) 
{

$fields->addFieldsToTab(
        'Root.Main',
        [
            LinkField::create(
                'LinkShop',
                'LinkShop',
                $this
            )
        ]
    );
}

}

I get the following Error in log and the settings page shows error.

[2019-02-28 11:43:13] error-log.ERROR: Uncaught Exception Error: "Call to undefined method CustomSiteConfig::exists()" at /var/www/domain/vendor/gorriecoe/silverstripe-linkfield/src/LinkField.php line 151 {"exception":"[object] (Error(code: 0): Call to undefined method CustomSiteConfig::exists() at /var/www/domain/vendor/gorriecoe/silverstripe-linkfield/src/LinkField.php:151)"} []

jrson83 commented 5 years ago

Nevermind I had to use $this->owner