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 /

Strange SiteConfig issue


Reply


5 Posts   1526 Views

Avatar
Pigeon

Community Member, 243 Posts

8 June 2010 at 3:02am

I'm running SilverStripe 2.4 from the 2.4 svn branch (r106221)

My SiteConfig started behaving strangely after a recent svn update. I am recieveing an error when attempting to save my SiteConfig. The issue seems to be that fields from the Page getCMSFields method are being 'saveInto'-ed the SiteConfig object causing this error:

ERROR [User Error]: Uncaught Exception: DataObject->getComponent(): Could not find component 'WidgetArea'.
IN POST /admin/EditForm
Line 1225 in /xxxx/xxxx/public_html/sapphire/core/model/DataObject.php

Source
======
1216: if($joinID) {
1217: $component = DataObject::get_one($class, "\"$joinField\" = $joinID");
1218: }
1219:
1220: if(!isset($component) || !$component) {
1221: $component = new $class();
1222: $component->$joinField = $this->ID;
1223: }
1224: } else {
* 1225: throw new Exception("DataObject->getComponent(): Could not find component '$componentName'.");
1226: }
1227:
1228: $this->components[$componentName] = $component;
1229: return $component;
1230: }
1231:

Trace
=====
<ul>DataObject->getComponent(WidgetArea)
line 66 of WidgetAreaEditor.php

WidgetAreaEditor->saveInto(SiteConfig)
line 998 of Form.php

Form->saveInto(SiteConfig)
line 379 of CMSMain.php

CMSMain->save_siteconfig(Array,Form,SS_HTTPRequest)
line 300 of Form.php

Form->httpSubmission(SS_HTTPRequest)
line 137 of RequestHandler.php

RequestHandler->handleRequest(SS_HTTPRequest)
line 155 of RequestHandler.php

RequestHandler->handleRequest(SS_HTTPRequest)
line 147 of Controller.php

Controller->handleRequest(SS_HTTPRequest)
line 282 of Director.php

Director::handleRequest(SS_HTTPRequest,Session)
line 127 of Director.php

Director::direct(/admin/EditForm)
line 127 of main.php

</ul>

My Page.php looks like this:

class Page extends SiteTree {
   
   public static $db = array(
      
   );
   
   public static $has_one = array(
      'WidgetArea' => 'WidgetArea'
   );

   
   function getCMSFields() {
      $fields = parent::getCMSFields();
      
      //remove for clutter reasons clutter
      $fields->removeFieldFromTab('Root.Content','GoogleSitemap');
      
      $fields->addFieldToTab('Root.Content.Widgets', new WidgetAreaEditor('WidgetArea'));
      
      return $fields;
   }
   
}

This seems to have started since the latest svn update. I will roll back and report back, but it would be interesting to see if anyone else has this problem.

Avatar
Pigeon

Community Member, 243 Posts

8 June 2010 at 3:23am

Ok, I did some rolling back to find the revision that caused this, and r106083 seems to be the last working one for the SiteConfig.

r106118 breaks it. Possibly a change in CMSMain.php in cms?

Avatar
Lis@

Community Member, 2 Posts

9 June 2010 at 4:25am

I consider your Tortoise SVN updating don't support given options of php form.
http://phpforms.net/tutorial/html-basics/php-forms.html

Avatar
joshy

Community Member, 57 Posts

9 June 2010 at 4:31am

If I were an algorithm, I'd mark that as spam ^.

Avatar
Pigeon

Community Member, 243 Posts

9 June 2010 at 4:35am

Lis@: Thanks, i can't say i fully understand what you said, or how it is relevant... but thanks. By the way, want to go out for a drink? You look kinda hot...