Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

SS3: updateCMSFields() for Custom Site Config


Reply


7 Posts   2474 Views

Avatar
zenmonkey

Community Member, 532 Posts

26 July 2012 at 4:13am

I get this error on SS3 with my custom site config

Declaration of CustomSiteConfig::updateCMSFields() should be compatible with that of DataExtension::updateCMSFields()

This is my Custom Site Config

class CustomSiteConfig extends DataExtension {

static $db = array(
   //Business Info
'BusinessName' => 'Varchar',
'StreetAddress' => 'Varchar',
'City' => 'Varchar',
'Province' => 'Varchar',
'PostalCode' => 'Varchar',
'PhoneNumber' => 'Varchar',
'FaxNumber' => 'Varchar',
'MainEmail' => 'Varchar',
'SiteEmail' => 'Varchar',
//Social Media
'Twitter' => 'Varchar',
'FacebookURL' => 'Varchar',
'GooglePlusURL' => 'Varchar',
'PinterestURL' => 'Varchar',
'YouTubeURL' => 'Varchar',
//About Info
'About' => 'HTMLText'
);

static $has_one = array(
   'Picture' => 'Image'
);

public function updateFormFields(FieldList &$fields) {
$fields->addFieldToTab("Root.Main", new TextField("BusinessName"));
$fields->addFieldToTab("Root.Main", new TextField("StreetAddress"));
$fields->addFieldToTab("Root.Main", new TextField("City"));
$fields->addFieldToTab("Root.Main", new TextField("Province"));
$fields->addFieldToTab("Root.Main", new TextField("PostalCode"));
$fields->addFieldToTab("Root.Main", new TextField("PhoneNumber"));
$fields->addFieldToTab("Root.Main", new TextField("FaxNumber"));
$fields->addFieldToTab("Root.Main", new EmailField("MainEmail", 'Main Contact Email'));
$fields->addFieldToTab("Root.Main", new EmailField("SiteEmail", 'Email for Contact Forms'));
$fields->addFieldToTab("Root.Main", new UploadField("Picture"));
$fields->addFieldToTab("Root.Main", new HtmlEditorField("About", "Sidebar About Copy"));
$fields->removeByName('Tagline');
$fields->addFieldToTab("Root.SocialMedia", new TextField("Twitter", 'Twitter User Name'));
$fields->addFieldToTab("Root.SocialMedia", new TextField("FacebookURL", 'Facebook URL'));
$fields->addFieldToTab("Root.SocialMedia", new TextField("GooglePlusURL", 'Google+ URL'));
$fields->addFieldToTab("Root.SocialMedia", new TextField("PinterestURL", 'Pinterest URL'));
$fields->addFieldToTab("Root.SocialMedia", new TextField("YouTubeURL", 'YouTube URL'));

}
}

Avatar
simon_w

Forum Moderator, 474 Posts

26 July 2012 at 8:31am

Remove the ampersand from updateFormFields(FieldList &$fields).

Avatar
zenmonkey

Community Member, 532 Posts

27 July 2012 at 1:21am

Okay, that fixed the error, but the Fields aren't showing up. I have the Object declared in my config. Well to clarify, the fields don't show up on my site on my web host (Dreamhost), it works fine only local MAMP stack

Avatar
neilcreagh

Community Member, 98 Posts

14 August 2012 at 1:53am

I think you should be using "updateCMSFields" not "updateFormFields".

For anyone else who stumbles upon this thread when trying to find out how to add additional site-wide settings (as I did) then I followed the instructions in the link below and it's working perfectly for me (the additional fields are appearing in the "Settings" area in the CMS):

[url]http://doc.silverstripe.org/framework/en/reference/siteconfig[/url]

Avatar
edwardlewis

Community Member, 32 Posts

10 September 2012 at 5:47am

The docs site is offline at the moment, so I cant check..

Has the code that goes in the templates to call the siteconfig values changed? These dont seem to be working for me anymore :(

<h1>$SiteConfig.Welcome1</h1>
<p>$SiteConfig.Welcome2</p>

Avatar
copernican

Community Member, 189 Posts

12 September 2012 at 3:48am

They have not changed, you still use $SiteConfig.Whatever

Avatar
edwardlewis

Community Member, 32 Posts

23 September 2012 at 2:12am

Lol.. schoolboy error. I didn't realise I had commented out a bunch of code. I need to add the SS bundle to TextMate for the highlighting syntax