I would like to add a TableField to a tab in the CMS to simple add a list of hyperlinks (title + link) to a page. Problem: in my current setup when I change/add a hyperlink on a page, the change is reflected on all other pages as well. What should I change to prevent this from happening?
//mysite/code/Hyperlink.php
<?php
class Hyperlink extends DataObject
{
static $db = array (
'Title' => 'Text',
'Link' => 'Text'
);
static $has_one = array (
'CaseExamplePage' => 'CaseExamplePage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Title'),
new TextField('Link')
);
}
}
?>
//mysite/code/CaseExamplePage.php
<?php
class CaseExamplePage extends Page {
public static $has_many = array(
'Hyperlinks' => 'Hyperlink'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
// Add Hyperlinks tab
$tblf = new TableField(
//$this,
'Hyperlinks',
'Hyperlink',
array('Title' => 'Title', 'Link' => 'Link'),
array('Title' => 'TextField', 'Link' => 'TextField'),
null,
"Hyperlink.CaseExamplePageID",
$this->ID
);
$fields->addFieldToTab('Root.Content.Hyperlinks', $tblf);
(...)