A module for managing a data object that has only a single record (similar to site config)
A module for managing a data object that has only a single record (similar to site config).
composer require bluehousegroup/silverstripe-single-record
<?php //MySetting.php
use ...
class MySetting extends DataObject
{
private static $db = [
"MyField" => "Varchar(255)",
];
private static $table_name = 'MySetting';
public $single_record = true;
public function getCMSFields()
{
$fields = new FieldList(
new TabSet(
"Root",
$tabMySettings = new Tab(
'My Settings',
$myField = new TextField("MyField", _t(self::class . '.MYFIELD', "My Field"))
)
),
new HiddenField('ID')
);
$tabMySettings->setTitle(_t(self::class . '.TABMYSETTINGS', "My Settings"));
$this->extend('updateCMSFields', $fields);
return $fields;
}
}
<?php //MySettingAdmin.php
use ...
use BluehouseGroup\SingleRecord\SingleRecordModelAdmin;
class MySettingAdmin extends SingleRecordModelAdmin
{
private static $url_segment = 'my-settings';
private static $menu_title = 'My Settings';
protected $tree_class = 'MySetting';
}
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem