Thanks for the quick reply!
However, I don't fully understand what do you mean. Can you please be more specific and give me more details?
In the meantime I have changed the relationship to many-many since I would like to share the same headline among pages.
I would like to restrict the headlines availablity/selection in ManyManyDataObjectManager / ManyManyComplexTableField.
E.g. having 'english' headlines available for selection for english pages and german headlines for german pages.
Does my headline data object store locale when it is created somehow or should I make it translatable as well?
Thanks.
Harl
It looks like this:
class Headline extends DataObject {
static $db = array(
'Title' => 'Varchar',
'Text' => 'HTMLText',
);
static $has_one = array(
'Image' => 'Image',
);
static $belongs_many_many = array(
'Pages' => 'Page'
);
function getThumbnail() {
$Image = $this->Image();
if ($Image) {
return $Image->CMSThumbnail();
}
else {
return null;
}
}
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push(new TextField('Title'));
$textField = new SimpleTinyMCEField('Text', 'Text', array(), 3);
$textField->setButtons(array(
'bold,italic,underline,|,link,unlink,anchor'
));
$fields->push($textField);
$fields->push(new ImageField('Image'));
return $fields;
}
}
class Page extends SiteTree {
static $db = array(
);
static $has_one = array(
);
static $many_many = array(
'Headlines' => 'Headline'
);
function getCMSFields() {
$fields = parent::getCMSFields();
// headlines tab
$headlinesTableField = new ManyManyDataObjectManager(
$this,
'Headlines',
'Headline',
array(
'Title' => 'Title',
'Text' => 'Text',
'Thumbnail' => 'Image',
),
'getCMSFields_forPopup'
);
$headlinesTableField->setAddTitle('a Headline');
$fields->addFieldToTab('Root.Content.Headlines', $headlinesTableField);
return $fields;
}
}