PHP code example of moo / hasoneselector
1. Go to this page and download the library: Download moo/hasoneselector library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
moo / hasoneselector example snippets
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;
}
//...
}