Closed thezenmonkey closed 1 year ago
Did you get it working in Elemental otherwise? I'm having issues with SS4.3 and Elemental. I get an error
Fatal Error (E_USER_ERROR): SilverStripe\Forms{closure}() I noticed that a field called 'VideoType' appears twice {"code":256,"message":"SilverStripe\Forms\{closure}()... 'VideoType' appears twice","file":"X:\project\vendor\silverstripe\framework\src\Forms\FieldList.php","line":175,"trace":[ ...
However, I only have the VideoType field once in my Elemental Block (custom block). Code:
<?php
use DNADesign\Elemental\Models\BaseElement;
use UncleCheese\DisplayLogic\Forms\Wrapper;
use SilverStripe\Forms\OptionsetField;
class CustomMediaElement extends BaseElement
{
...Model definitions etc...
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab(
'Root.Main',
$mediatype = new OptionsetField(
'MediaType',
'Media Type'
)
);
$mediatype->setSource(array(
'I' => 'Image',
'V' => 'Video',
'A' => 'Audio'
));
$mediatype->setEmptyString('');
$fields->addFieldToTab(
'Root.Main',
Wrapper::create(
OptionsetField::create(
'VideoType',
'Video Type',
array(
'Y' => 'YouTube',
'V' => 'Vimeo'
)
)
)->displayIf('MediaType')->isEqualTo('V')->end()
);
return $fields;
}
public function getType() {
return 'Custom Media';
}
}
Im having the same issue when I am using the Wrapper
inside Elemental.
you can use replaceField instead of creating new,
$fields->replaceField('VideoType', Wrapper::create( OptionsetField::create( 'VideoType', 'Video Type', array( 'Y' => 'YouTube', 'V' => 'Vimeo' ) ) ) )
Did you get it working in Elemental otherwise? I'm having issues with SS4.3 and Elemental. I get an error
Fatal Error (E_USER_ERROR): SilverStripe\Forms{closure}() I noticed that a field called 'VideoType' appears twice {"code":256,"message":"SilverStripe\Forms{closure}()... 'VideoType' appears twice","file":"X:\project\vendor\silverstripe\framework\src\Forms\FieldList.php","line":175,"trace":[ ...
However, I only have the VideoType field once in my Elemental Block (custom block). Code:
<?php use DNADesign\Elemental\Models\BaseElement; use UncleCheese\DisplayLogic\Forms\Wrapper; use SilverStripe\Forms\OptionsetField; class CustomMediaElement extends BaseElement { ...Model definitions etc... public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab( 'Root.Main', $mediatype = new OptionsetField( 'MediaType', 'Media Type' ) ); $mediatype->setSource(array( 'I' => 'Image', 'V' => 'Video', 'A' => 'Audio' )); $mediatype->setEmptyString(''); $fields->addFieldToTab( 'Root.Main', Wrapper::create( OptionsetField::create( 'VideoType', 'Video Type', array( 'Y' => 'YouTube', 'V' => 'Vimeo' ) ) )->displayIf('MediaType')->isEqualTo('V')->end() ); return $fields; } public function getType() { return 'Custom Media'; } }
I believe the display logic mechanism would work if the correct field name was used. If that was not possible, it would still be an issue worth raising at the Elemental module.
Closing this issue since it's outdated and we're now on Silverstripe CMS 4.12.0 and Display Logic 2.0.5.
If the problem with the Display Logic module persists, feel free to open a new bug report and provide replication steps and information on what version of Silverstripe CMS and the module you're using.
Another solution I found was using inline editable on your Element Model
private static $inline_editable = false;
Can't use ShowTitle checkbox field on BaseElement as a trigger. Likely because it's part of TextCheckboxGroupField instead of a regular CheckboxField. It's minor, but since Elemental is pretty core to SS moving forward it would be useful if we could use that field as a trigger.