-2
if (class_exists('DataObjectManager'))
    $a='DataObjectManager';
else
    $a='ComplexTableField';
$f->addFieldToTab(
    "Root.Content.Panels",
    new $a(
        $this,
        'Panels',
        'NivoSliderPanel',
        array('Name' => 'Name','Thumbnail' => 'Thumbnail'),
        'getCMSFields_forPopup'
    )
);

i am using a nivo silder can anyone help me to understand is piece of code. I am getting a error ComplexTableField could not found.

xeraa
  • 10,456
  • 3
  • 33
  • 66

1 Answers1

1

ComplexTableField is from Silverstripe 2.4 and no longer works in 3.0 or 3.1.

If you are getting an error that ComplexTableField could not found then I am guessing you are using Silverstripe 3.1.

Silverstripe 2.4 code will not work in 3.1. This code needs modification to work in 3.1.

In Silverstripe 3.1 GridField has replaced ComplexTableField.

Using GridField looks something like this:

private static $has_many = array (
    'Panels' => 'Panel'
);

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

    $panelsField = new GridField(
        'Panels',
        'Panels',
        $this->Panels(),
        GridFieldConfig_RecordEditor::create()
    ); 
    $fields->addFieldToTab('Root.Panels', $panelsField);

    return $fields;
}
3dgoo
  • 15,716
  • 6
  • 46
  • 58