cms-niceties/src/Extensions/EmbedObjectField.php
2021-06-19 21:30:03 +02:00

48 lines
1.3 KiB
PHP
Executable File

<?php
namespace A2nt\CMSNiceties\Extensions;
use Sheadawson\Linkable\Forms\EmbeddedObjectField;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\CompositeField;
use SilverStripe\Forms\LiteralField;
use SilverStripe\ORM\FieldType\DBHTMLText;
class EmbedObjectField extends EmbeddedObjectField
{
/**
* @param array $properties
* @return mixed|DBHTMLText
*/
public function FieldHolder($properties = [])
{
$name = $this->getName();
$fields = [
CheckboxField::create(
$name . '[autoplay]',
_t(self::CLASS.'AUTOPLAY', 'Autoplay video?')
)->setValue($this->object->getField('Autoplay')),
CheckboxField::create(
$name . '[loop]',
_t(self::CLASS.'LOOP', 'Loop video?')
)->setValue($this->object->getField('Loop')),
CheckboxField::create(
$name.'[controls]',
_t(self::CLASS.'CONTROLS', 'Show player controls?')
)->setValue($this->object->getField('Controls'))
];
return CompositeField::create(array_merge([
LiteralField::create(
$name.'Options',
parent::FieldHolder($properties)
)
], $fields));
}
}