My custom Elemental Extension
renders a GroupedDropdownField to select a Video from a Video - Dataobject.
This works well when
inline_editable is set to false.
When i try to set inline_editable to true, the GroupedDropdownField is not rendered.
How can i display the GroupedDropdownField when inline_editing is true?
<?php
use DNADesignElementalModelsBaseElement;
use SilverStripeFormsGroupedDropdownField;
use SilverStripeFormsTextField;
use SilverStripeFormsFieldList;
use SilverStripeORMFieldTypeDBField;
use SilverStripeViewHTML;
use SilverStripeDevDebug;
use SilverStripeDevBacktrace;
class VideoElement extends BaseElement
{
private static $singular_name = 'Videoelement';
private static $plural_name = 'Videoelements';
private static $description = 'add a Video';
private static $icon = 'fa fa-video-camera outline mt-1';
private static $table_name = 'VideoElementBlock';
private static $inline_editable = false;
private static $has_one = [
'Video' => VideoObject::class
];
private static $owns = [
'Video',
];
public function getCMSFields()
{
$fields = parent::getCMSFields();
$categories = VideoCatObject::get();
$subcategoryArray = [];
foreach ($categories as $category) {
$subcategoryArray[$category->Title] = $category->Videos()->map('ID', 'Title')->toArray();
}
$fields->addFieldToTab('Root.Main', GroupedDropdownField::create(
'VideoID',
'Video',
$subcategoryArray
));
return $fields;
}
public function getSummary()
{
if ($this->Video() && $this->Video()->exists()) {
return $this->getSummaryThumbnail() . $this->Video()->Title;
}
return '';
}
public function getSummaryThumbnail()
{
$data = [];
if ($this->Video() && $this->Video()->exists()) {
$data['Image'] = $this->Video()->AutoThumbnail()->ScaleWidth(36)->CropHeight(36);
}
return $this->customise($data)->renderWith('VideoElementThumbnail');
}
public function fieldLabels($includerelations = true)
{
$labels = parent::fieldLabels($includerelations);
$labels['EmbeddedObject'] = _t(__CLASS__ . '.EmbeddedObjectLabel', 'Content from oEmbed URL');
return $labels;
}
protected function provideBlockSchema()
{
$blockSchema = parent::provideBlockSchema();
if ($this->Video() && $this->Video()->exists()) {
$blockSchema['fileURL'] = $this->Video()->AutoThumbnail()->getURL();
$blockSchema['fileTitle'] = $this->Video()->getTitle();
}
return $blockSchema;
}
public function getType()
{
return 'Video';
}
}
question from:
https://stackoverflow.com/questions/65861480/silverstripe-4-elemental-groupeddropdownfield-inline-editable 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…