Jump to:

5516 Posts in 1734 Topics by 1221 members

Customising the CMS

SilverStripe Forums » Customising the CMS » SS3: updateCMSFields() for Custom Site Config

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2143 Views
  • zenmonkey
    Avatar
    Community Member
    527 Posts

    SS3: updateCMSFields() for Custom Site Config Link to this post

    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'));

    }
    }

  • simon_w
    Avatar
    Forum Moderator
    471 Posts

    Re: SS3: updateCMSFields() for Custom Site Config Link to this post

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

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: SS3: updateCMSFields() for Custom Site Config Link to this post

    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

  • neilcreagh
    Avatar
    Community Member
    90 Posts

    Re: SS3: updateCMSFields() for Custom Site Config Link to this post

    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):

    http://doc.silverstripe.org/framework/en/reference/siteconfig

  • edwardlewis
    Avatar
    Community Member
    32 Posts

    Re: SS3: updateCMSFields() for Custom Site Config Link to this post

    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>

  • IOTI
    Avatar
    Community Member
    189 Posts

    Re: SS3: updateCMSFields() for Custom Site Config Link to this post

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

  • edwardlewis
    Avatar
    Community Member
    32 Posts

    Re: SS3: updateCMSFields() for Custom Site Config Link to this post

    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

    2143 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.