user9013856
user9013856

Reputation: 328

SilverStripe Display logic duplicate error

I get an error in SilverStripe for duplication when using "DisplayLogicWrapper::create" it does it no matter if its upload field or gridfield or any other seems the same issue. Any help is appreciated!

PHP 5.6.30, silverstripe/cms 3.5.3, unclecheese/display-logic 1.5 plugin: https://github.com/unclecheese/silverstripe-display-logic/tree/1.5.0#dealing-with-non-standard-form-fields

private static $has_one = array(
  'IntroBackgroundIMG' => 'Image',
);

DisplayLogicWrapper::create(
  UploadField::create('IntroBackgroundIMG', 'Background Image'))
  ->displayIf("BackgroundType")->isEqualTo("img")
  ->end(),

error received:

[User Error] collateDataFields() I noticed that a field called 
'IntroBackgroundIMG' appears twice in your form: '(unknown form)'. One is a 
'UploadField' and the other is a 'UploadField'

Upvotes: 1

Views: 297

Answers (1)

scrowler
scrowler

Reputation: 24406

I'm not familiar with this module, but it looks like you're trying to display the UploadField conditionally, in which case perhaps you need to ensure that the default UploadField that is scaffolded automatically gets removed first:

public function getCMSFields()
{
    $fields = parent::getCMSFields();

    $fields->removeByName('IntroBackgroundIMG');
    $fields->addFieldToTab('Root.Main', DisplayLogicWrapper...

Upvotes: 1

Related Questions