PHP code example of burnbright / silverstripe-hasonefield
1. Go to this page and download the library: Download burnbright/silverstripe-hasonefield 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/ */
burnbright / silverstripe-hasonefield example snippets
use SilverShop\HasOneField\HasOneButtonField;
private static $has_one = [
'Address' => 'Address'
];
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Main",
HasOneButtonField::create($this, "Address")
);
return $fields;
}
$property = HasOneButtonField::create(
$this,
'Address'
);
$property
->getConfig()
->getComponentByType(HasOneAddExistingAutoCompleter::class)
->setSearchList(Property::get()->filter("Country", "GB"));
$fields->addFieldToTab(
'Root.Main',
$property
);