mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-08 18:51:12 +02:00
66 lines
1.1 KiB
PHP
66 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
/**
|
||
|
* Popup form action menu for "more options"
|
||
|
*
|
||
|
* Only works with react forms at the moment
|
||
|
*/
|
||
|
class PopoverField extends FieldGroup
|
||
|
{
|
||
|
private static $cast = [
|
||
|
'PopoverTitle' => 'HTMLText'
|
||
|
];
|
||
|
|
||
|
/**
|
||
|
* Use custom react component
|
||
|
*
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $schemaComponent = 'PopoverField';
|
||
|
|
||
|
/**
|
||
|
* Optional title on popup box
|
||
|
*
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $popoverTitle = null;
|
||
|
|
||
|
/**
|
||
|
* Get popup title
|
||
|
*
|
||
|
* @return string
|
||
|
*/
|
||
|
public function getPopoverTitle()
|
||
|
{
|
||
|
return $this->popoverTitle;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Set popup title
|
||
|
*
|
||
|
* @param string $popoverTitle
|
||
|
* @return $this
|
||
|
*/
|
||
|
public function setPopoverTitle($popoverTitle)
|
||
|
{
|
||
|
$this->popoverTitle = $popoverTitle;
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
public function getSchemaDataDefaults()
|
||
|
{
|
||
|
$schema = parent::getSchemaDataDefaults();
|
||
|
if($this->getPopoverTitle()) {
|
||
|
$data = [
|
||
|
'popoverTitle' => $this->getPopoverTitle()
|
||
|
];
|
||
|
if(isset($schema['data'])) {
|
||
|
$schema['data'] = array_merge($schema['data'], $data);
|
||
|
} else {
|
||
|
$schema['data'] = $data;
|
||
|
}
|
||
|
}
|
||
|
return $schema;
|
||
|
}
|
||
|
}
|