21309 Posts in 5738 Topics by 2603 members
General Questions
SilverStripe Forums » General Questions » SS3 updateCMSFields issue when decorating extended Page class
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 320 Views |
-
SS3 updateCMSFields issue when decorating extended Page class

23 November 2012 at 1:14pm
Hi all,
I'm upgrading the shop module to SS3. https://github.com/burnbright/silverstripe-shop
I'm having an issue when I try to add a simple Decorator to my Product and then try using updateCMSFields... simply put, it doesn't work at all... not even a simple Debug::dump("working") does nothing. Here is my code.
class ProductVariationDecorator extends DataExtension{
/**
* Adds variations specific fields to the CMS.
*/
public function updateCMSFields(FieldList $fields) {
Debug::dump("working");
$fields->addFieldToTab('Root.Variations',new HeaderField("Variation Attribute Types"));
}...
-
Re: SS3 updateCMSFields issue when decorating extended Page class

30 November 2012 at 2:14am
Silly question but you did you add Object::add_extension('Product', 'ProductVariationDecorator'); to your _config.php?
I noticed in Product.php starting at line 79
$tempextvar = $this->get_static('SiteTree','runCMSFieldsExtensions');
$this->disableCMSFieldsExtensions();
$fields = parent::getCMSFields();
if($tempextvar){
$this->enableCMSFieldsExtensions();
}and on line 123
if($tempextvar){
$this->extend('updateCMSFields', $fields);
}perhaps that could be causing issues?
-
Re: SS3 updateCMSFields issue when decorating extended Page class

30 November 2012 at 7:57am
Hey ya IOTI,
Thanks heaps for your reply,
1. Yes _config is correct
2. the code in product is fine... I have tested by removing all of the code you mentioned, but still no luck.I'll have another look in the next hour and see if I have any more luck.
All of my other decorators seem to work fine. Hmmm just found this in the changelogs for 3
http://doc.silverstripe.org/framework/en/changelogs/3.0.0
Settings-related fields move from SiteTree->getCMSFields() to new SiteTree->getSettingsFields() [getcmsfields] ¶
The fields and tabs are now split into two separate forms, which required a structural change to the underlying class logic. In case you have added or removed fields in the "Behaviour" or "Access" tab, please move these customizations to a new getSettingsFields() method. In case of SiteTree extension through updateCMSFields() and a decorator/extension, please use the new updateSettingsFields() instead.?
Cheers Heaps
J -
Re: SS3 updateCMSFields issue when decorating extended Page class

30 November 2012 at 8:02am
Did you remove the
$this->extend('updateCMSFields', $fields);
part as well? That one would need to stay
. Only asking because you said you removed "all of the code" -
Re: SS3 updateCMSFields issue when decorating extended Page class

30 November 2012 at 9:51am
It's fine now. I'm so sorry IOTI
I fixed something else and it seems fine now.
But yes, the whole:
//prevent calling updateCMSFields extend function too early
$tempextvar = $this->get_static('SiteTree','runCMSFieldsExtensions');
$this->disableCMSFieldsExtensions();
...
...
if($tempextvar){
$this->extend('updateCMSFields', $fields);
}is a bit strange... I've taken it out and it seems fine. I'll have a chat with Jeremy (burnbright) and see if he feels we still need it for SS3
Thanks so much for your help.
J
-
Re: SS3 updateCMSFields issue when decorating extended Page class

30 November 2012 at 9:56am
and yes I left in $this->extend('updateCMSFields', $fields);
J
-
Re: SS3 updateCMSFields issue when decorating extended Page class

30 November 2012 at 9:57am
Cool, happy to hear you got it working!
-
Re: SS3 updateCMSFields issue when decorating extended Page class

22 May 2013 at 12:03am
I am using the silverstripe ecommerce module https://github.com/sunnysideup/silverstripe-ecommerce/
I got the same problem. There are 2 lines as mentioned by nimesodelta:
//prevent calling updateSettingsFields extend function too early
$siteTreeFieldExtensions = $this->get_static('SiteTree','runCMSFieldsExtensions');
$this->disableCMSFieldsExtensions();i have to take it out as well
| 320 Views | ||
|
Page:
1
|
Go to Top |



