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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Widgets /

Discuss SilverStripe Widgets.

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

HTMLTextField in Widget

Go to End

16 Posts   6433 Views


Community Member, 176 Posts

9 October 2010 at 4:23am

I've got a very simple widget, where I want the user to edit HTMLText field. I've tried
HTMLEditorField, SimpleTinyMCEField and SimpleWysiwygField from the DOM.

The HTMLEditorField shows the editor, but the content is neither loaded nor saved. SimpleTinyMCEField and SimpleWysiwygField show the content but not any tiny mce editor fields.

Any pointers to get this working?


class HTMLTextWidget extends Widget {
	static $db = array(
		'Title' => 'Text',
		'WidgetContent' => 'HTMLText',

	static $title = "Content";
	static $cmsTitle = "Content Widget";
	static $description = "Add a content block to the sidebar";

	function Title() {
		return $this->Title;

	function getCMSFields() {
		return new FieldSet(
			new TextField("Title", "Title"),
			//new HTMLEditorField("WidgetContent", "Content")
			new SimpleTinyMCEField("WidgetContent", "Content")
			//new SimpleWysiwygField("WidgetContent", "Content")
			//new TextareaField("WidgetContent", "Content")



Forum Moderator, 1899 Posts

9 October 2010 at 5:38am

Edited: 09/10/2010 5:39am

Hi Marijn,

I just looked at this and I'd say it was something in tinyMCE that is not "getting" the contents of the text box. I say that because the text in the database (if you were to edit it manually) appears in the the textarea "behind" the tinyMCE and then gets submitted for saving and can be seen by logging $_REQUEST['Widget'] in \cms\code\WidgetAreaEditor.php function saveInto(DataObject $record).

So I think it is something todo with the way widget areas use indexes type stuff to hold multiple items e.g. 'Widget[SideBar][30][WidgetContent]' is what the name of the field in my browser - instead of 'Form_EditForm_Content' for teh main page content.

So, as I said, I figure it is something in the communication between tinyMCE and the textarea due to the id. I had issues when I tried to do jQuery finding a widget item by id in the past and ended up doing something else much more simple without the jQuery due to these issues.

Hope this helps,


p.s. I was testing with 'new HTMLEditorField("WidgetContent", "WidgetContent")'


Community Member, 43 Posts

22 October 2010 at 2:55am


this is probably the same problem that the HtmlContentWidget has:

As far as I know the HtmlContentWidget is not updated anymore. Since it is a common request, I was thinking about creating a new Modul but never found the time. Would you be willing to release your widget for others to use?



Community Member, 176 Posts

22 October 2010 at 7:49pm

I ended up just using a plain text field, as the particular user this was for is quite tech savvy. If I ever develop a HTML Widget I'll make sure to release it.


Community Member, 400 Posts

19 November 2010 at 1:32pm

hello @MarijnKampf,

I have come across this problem before. What I did is to use some goodies which ships with the DataObjectManager Module. There are some fields called SimpleTinyMCEField, SimpleHTMLEditorField, etc.

take a look at them, they cant do much, at least they can help you.



Community Member, 176 Posts

10 February 2011 at 1:43am

Hi Nivanka,

It's been a while, but I've come across another scenario where it would be nice to have an HTML widget, I had a brief look into SimpleTinyMCEField and SimpleHTMLEditorField, but couldn't get them to work out of the box. (The fields aren't shown in my widget). Do you have some sample code of using them in a widget?




Forum Moderator, 1899 Posts

10 February 2011 at 11:06pm

I remember seeing something by Martijn on the google dev list about a patch to allow this - as I said before it all comes down to the ids being stuff like "Widget[SideBar][42][LinkToSiteTreeID]" - here is is


Community Member, 219 Posts

18 January 2012 at 11:13pm

Edited: 18/01/2012 11:21pm

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

Go to Top