Hi!
I've run into an issue with a DataObject that is related to a Page. A minimal reproducible example is the following.
I have a TestObject which extends a DataObject
class TestObject extends DataObject{
static $db = array(
'Name' => 'VarChar(255)'
);
static $has_one = array(
'LinkedPage' => 'SiteTree'
);
}
Then I have a page that has a list of TestObjects
class TestPage extends Page{
static $has_many = array(
'TestObjects' => 'TestObject'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new GridField('TestObjects', 'TestObjects', $this->TestObjects(), GridFieldConfig_RecordEditor::create()), 'Metadata');
return $fields;
}
}
class TestPage_Controller extends Page_Controller{
}
Now create a Page of type TestPage and add a new TestObject to it. The TestObject edit-page does not show a TreeDropdownField, instead it shows the title of the TestPage. It appears that the TreeDropdownField is there, but it is automatically set to readonly. After saving the TestObject, the column in the database shows a reference to the TestPage containing the TestObject.
There appears to be a workaround for the issue. If one adds another has_many relation of type SiteTree, the editor now shows a non-readonly TreeDropdownField below the first readonly TreeDropdownField.
Am I overlooking something here or is it a bug?