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.


Discuss SilverStripe Widgets.

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

Bad Widget Class Name Given


7 Posts   1528 Views

Carbon Crayon

1 April 2009 at 1:56am (Last edited: 1 April 2009 4:00am), Community Member, 598 Posts

Hi Guys

I am using widgets for the first time on a project and I seem to have run into a major problem. On install they seems to work fine, I Installed the Links and Google Calender widgets and all was good (I'm not using the blog module at all, just widget areas on other pages).

But as soon as I started adding more/removing widgets it all breaks and I get 'Bad Class name given' in the widget area when dragging a widget across.

I tried clearing the widget related tables in the database and setting the class Enum back to just 'Widget' before doing a dev/build but still the same problem. The only way I have managed to get it back is via a complete reinstall and then it just happens again as soon as I start adding more widgets.

Interestingly when it breaks firebug throws a javascript error: $(widget).getElementsByClassName is not a function, which appears to imply that Prototype is not being loaded properly, but I can't think how adding/removing widgets could break that?

Also if there is already a widget in the area, then it works adding's when the area is empty that it breaks....

Any help would be most appreciated.



1 April 2009 at 5:07am (Last edited: 1 April 2009 5:10am), Community Member, 57 Posts

Probably worth posting the list of widgets you're trying to use to see if anyone can spot something obvious. If you're debugging with Firebug/Firefox it's worth closing Firefox completely and checking it's gone in TaskManager, I've had a few issues with Firebug when debugging javascript.

But, other than that, I would try and narrow it down a bit:

Try adding / removing the widgets one at a time to see if you can identify which one, or combination breaks it. Start with the simplest one and add the next most complex, then do it the other way arround.

Speeding things up:
You shouldn't have to reinstall if it borks, just delete the relevant rows from the WidgetEnabledPage table (set it to 0 (zero)) (replace WidgetEnabledPage with the name of you custom page). You should clear out any related entries in the Widget and WidgetArea tables but it shouldn't cause you problems if you don't, it'll just be untidy in there. Try this on a dev site while you're testing. I don't think you need to delete the widget code folders or rebuild the database.

Hope that helps

Carbon Crayon

1 April 2009 at 6:17am Community Member, 598 Posts

Hi FengshuiElephant, thanks for the reply

Unfortunately, once this issue is here it doesn't seem to want to go away even when i remove all widgets and clear all the related database fields, then try adding a single widget (which works when the install is fresh).

The Widgets I tried initially were Links & google calender which worked, then I added youtube which broke everything. Then on a fresh install Links and google working, then added my own widget with just a simple text field in, then everything broke, so I removed my widget and it was still broken....then removed all widgets and cleaned out the db, and installed the blog module. Still the same problem....but more sporadic on the blog, sometimes it adds them but errors on save, other times it gives the Bad Class Name error and very occasionally it will work completely.

I tried on a machine without firebug and I get the same result........

I am totally confused and I cant seem to get it back to working without completely clearing the db, which seems crazy as I am sure I have cleared all relevant columns/tables in the db.

Very confused :(

I guess I will try reinstalling and see if I can pick out any clearer pattern before it breaks. I am only at the development stage at the mo, so luckily there is no live site :)


1 April 2009 at 6:38am Community Member, 57 Posts

If you've removed the db entries (including the additional columns in the WidgetEnabledPage) and all of the widget code then you should be back to normal; if it isn't, there must be something left over.

You could try deleting the widget code, deleting the WidgetEnabledPage tables and deleting all the rows from Widget and WidgetArea tables before rebuilding the db. I can't think of anything that would be left after that.

It's very odd that it sometimes works completely and other times not, sounds like a race condition, or something that's dependent on network traffic. That would cause me to suspect the YouTube and Google Calendar widgets so I'd concentrate my testing there. If you can find out which widget is causing the problem (assuming that there's only one), you could try testing it different times when the network traffic is likely to be light / heavy to see if that makes a difference.

Let us know what you managed to find out. I'm interested in this because I have a similar problem, though I'm sure I caused mine.


1 April 2009 at 7:24am (Last edited: 1 April 2009 7:25am), Community Member, 57 Posts

The way I tracked down my error may help you.
I opened the CMS and Firebug's Net panel and clicked the XHR filter which just shows Ajax calls. One of the Ajax calls from the CMS was failing and I could see what it was sending to the server (hover over the red failure).

I'd misspelt one of the fields in my widget; HTMLEditorField instead of HtmlEditorField (it's case sensitive). This caused the Bad Widget Class Name Given error that you've got.

Carbon Crayon

1 April 2009 at 8:59am Community Member, 598 Posts

Yea I think you might be right, I ended up just doing a reinstall before I left work and then created 3 custom widgets with textfields and I had no issues. I will test it tomo by adding the calender widget and see if I can isolate the issue.

I guess I must have missed something in the db, but I couldn't see anything else....anyway I will let you know how I get on tomo.

Thanks again :)


18 January 2012 at 11:14pm (Last edited: 18 January 2012 11:22pm), Community Member, 218 Posts

We got our widgets working on all pages eventually, here's our solution. Hopefully it helps!