01/03/2012 1:15am

PHP | Working Example - Make a ComplexTableField work in SiteConfig


<?php


class CustomSiteConfig extends DataObjectDecorator {

function extraStatics() {
return array(
'has_many' => array(
'BannerImages' => 'BannerImage' //example DataObject
)
);
}

public function updateCMSFields(FieldSet $fields) {
//unbork CTF's
$this->ID = $this->owner->ID;
$fields->push(new HiddenField('ID', '', $this->owner->ID)); // never leave home without it!

$fields->addFieldToTab("Root", new Tab("BannerImages"), 'Access');
$fields->addFieldToTab("Root.BannerImages", new ComplexTableField($this->owner, 'BannerImages', 'BannerImage'));

return $fields;
}
}


Post Comment