SS4.4
I try to extend a SiteTree-Class and need to remove some fields.
I think that updateCMSFields gets called before the getCMSFields of the extended class.
So my removeField is not in affect…
But how to do it?
class OrderProductExtension extends Extension{
public function updateCMSFields(FieldList $fields) {
//DOES NOT WORK
$fields->removeFieldFromTab('Shop','Preise');
//DOES WORK
$fields->addFieldToTab('Root.Main',new LiteralField("Test","Test"));
}
}
Because I try to exntend another modul of mine I came up with adding a hook-point to my original class.
the updateCMSFields-Method which seems to be a build-in hook aswell seems to get inserted in the beginning of getCMSFields…
class Product extends Page{
public function getCMSFields(){
$fields=parent::getCMSFields();
**$this->extend('addExtension', $fields);**
return $fields;
}
}
class ProductExtension extends DataExtension{
public function **addExtension(FieldList $fields)**{
$fields->removeFieldFromTab('Root.Shop','Price');
}
}