Reputation: 423
I have created the Page, Data Object and Model Admin given below.
Page
class MyPage extends Page {
private static $db = [];
private static $singular_name = "My Page";
private static $plural_name = "My Pages";
private static $description = 'A page created for testing';
}
Data Object
use SilverStripe\ORM\DataObject;
class MyDataObject extends DataObject {
private static $db = [
'Test' => 'Int'
];
}
Model Admin
<?php
use SilverStripe\Admin\ModelAdmin;
class MyAdmin extends ModelAdmin {
private static $managed_models = [
'MyPage',
'MyDataObject'
];
private static $url_segment = 'my-pages';
private static $menu_title = 'My Page Admin';
}
When I create a new "MyDataObject" it creates and publishes the object when I click the save button. But when I create a "MyPage" it is still a draft after clicking the save button. I have to open the page from Pages Tree and hit the Publish button to publish the page.
Upvotes: 0
Views: 414
Reputation: 423
You have to change your page's code as shown below. (Just add this line - private static $versioned_gridfield_extensions = true; )
<?php
class MyPage extends Page {
private static $versioned_gridfield_extensions = true;
private static $db = [];
private static $singular_name = "My Page";
private static $plural_name = "My Pages";
private static $description = 'A page created for testing';
}
Upvotes: 2
Reputation: 71
Page is versioned by default, data objects are not.
https://docs.silverstripe.org/en/4/developer_guides/model/versioning/
Upvotes: 2