Skip to content

Latest commit

 

History

History
54 lines (38 loc) · 1.77 KB

README.md

File metadata and controls

54 lines (38 loc) · 1.77 KB

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.