Hi,
I would like to make sure that all pages created of a particular template type are not shown in menus. Is it possible to set this value from the Page_Controller and then remove the checkbox / make the checkbox disabled so that users cannot make this page visible in menus?
Thanks
Robin
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Just to clarify - this is what I've got so far:
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab('Root.Behaviour', 'ShowInMenus')
$fields->dataFieldByName('ShowInMenus')->setValue(0);
return $fields;
}
which hides the field ok, but I can't seem to set the value to 0
You can set the default value of the field using static $defaults. Then remove the field as you have done.
// on your custom page type
static $defaults = array(
'ShowInMenus' => 0
);
Perfect. Thank you.