Thanks for your advice - I did what I thought to try but just got a redeclare error. My code is as follows, any further assistance would be appreciated.
HomePage.php (uses DOM)
class HomePage extends Page
{
static $has_many = array (
'InfoBoxes' => 'InfoBox'
);
static $has_one = array(
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new DataObjectManager(
$this, // Controller
'InfoBoxes', // Source name
'InfoBox', // Source class
array('Title' => 'Title', 'Description' => 'Description', 'Link' => 'Link', 'Image' => 'Image'), // Headings
'getCMSFields_forPopup' // Detail fields function or FieldSet
);
$f->addFieldToTab("Root.Content.InfoBoxes", $manager);
return $f;
}
MultiBox Template (needs to also have unique DOM instances for each page use)
static $has_many = array (
'InfoBoxes' => 'InfoBox'
);
function getCMSFields(){
$fields = parent::getCMSFields();
$manager = new DataObjectManager(
$this, // Controller
'InfoBoxes', // Source name
'InfoBox', // Source class
array('Title' => 'Title', 'Description' => 'Description', 'Image' => 'Image'), // Headings
'getCMSFields_forPopup' // Detail fields function or FieldSet
);
$fields->addFieldToTab("Root.Content.InfoBoxes", $manager);
$fields->addFieldToTab("Root.Content.Main", new ImageField('TopImage'));
$fields->addFieldToTab("Root.Content.Banners", new HTMLEditorField('BannerArea'));
return $fields;
}
Class InfoBox
class InfoBox extends DataObject
{
static $db = array (
'Title' => 'Text',
'Description' => 'Text',
'Link' => 'Text'
);
static $has_one = array (
'HomePage' => 'HomePage',
'Image' => 'Image'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Title'),
new TextField('Description'),
new TextField('Link'),
new ImageField('Image')
);
}
}