Skip to content

HasOneSelector is a module that provides CMS field to manage data object defined in a has_one relation.

License

Notifications You must be signed in to change notification settings

satrun77/silverstripe-hasoneselector

Repository files navigation

HasOne Selector

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version License

HasOneSelector is a module that provides CMS field to manage data object defined in a has_one relation.

Requirements

  • SilverStripe CMS ^5.0

Installation via Composer

composer require moo/hasoneselector

Usage

use SilverStripe\ORM\DataObject;
use SilverStripe\CMS\Model\SiteTree;
use Moo\HasOneSelector\Form\Field;

class Resource extends DataObject
{
    //...
}

class Page extends SiteTree
{
    //...
    private static $has_one = [
        'Resource' => Resource::class,
    ];

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $resource = Field::create('Resource', 'Resource', $this, Resource::class);
        $fields->addFieldToTab('Root.Main', $resource);

        return $fields;
    }

    //...
}

License

This module is under the MIT license. View the LICENSE file for the full copyright and license information.

About

HasOneSelector is a module that provides CMS field to manage data object defined in a has_one relation.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published