Reputation: 1914
I'm trying to remove the Visibility FieldGroup from the Page Main.Settings tab. I took a wild guess and wrote this in Page.php:
function getSettingsFields() {
$fields = parent::getSettingsFields();
$fields->removeByName('Visibility');
return $fields;
}
..It did the trick, but strangely it only works when the Locale is English. Im guessing the removeByName parameter is refering to the field label for the Visibility fieldgroup, and value for this label is different for each Locale (language). In the SiteTree.php where this fieldgroup is created, I couldn't find an actual name for the FieldGroup "Visibility".
How can I remove this FieldGroup in a way that doesn't regard Locales?
Upvotes: 2
Views: 195
Reputation: 1914
Since 'Visibility' is a translated fieldname, I looked up the _t
reference for this specific fieldname and placed that in removeByName
instead of the fixed string 'Visibility', so it follows all Locales. Following code removes the unnamed FieldGroup.
function getSettingsFields() {
$fields = parent::getSettingsFields();
$fields->removeByName(_t('SiteTree.Visibility', 'Visibility'));
return $fields;
}
Upvotes: 3