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.

Data Model Questions /

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

SilverStripe 3.0. ModelAdmin and HTMLEditor

Go to End

10 Posts   4267 Views


Community Member, 2 Posts

27 June 2012 at 9:53pm

I want to use HTMLEditor field in ModelAdmin, but when I click on icon like (image, url) in HTML editor I get this error
[User Error] ModelAdmin::init(): Invalid Model class

How can use HTML editor field in ModelAdmin?


class TaskModelAdmin extends ModelAdmin
	static $url_segment = 'task';
	static $menu_title = 'Tasks';
	static $menu_priority = 1;
	public $showImportForm = false;
	//static $url_priority = 50;
	public static $managed_models = array('Task');

class Task extends DataObject
	public static $db = array(
		'Name' => 'Varchar(500)',
		'Description' => 'HTMLText',
		'Bug' => 'Boolean',
		'StartDate' => 'Date',
		'EndDate' => 'Date'



Community Member, 1 Post

5 September 2012 at 2:57am

I'm also having this issue. Were you able to figure anything out?


Community Member, 24 Posts

17 September 2012 at 11:24pm

Edited: 18/09/2012 12:29am

Yep, definitely an issue.

This can be added to your ModelAdmin subclass to produce a different output from /admin/[modeladminclass]/EditorToolbar/LinkForm/forTemplate

Temporary solution (tested minimally):

class ModelAdminHtmlEditorField_Toolbar extends HtmlEditorField_Toolbar {
public function forTemplate() {
return sprintf(
'<div id="cms-editor-dialogs" data-url-linkform="%s" data-url-mediaform="%s"></div>',
Controller::join_links($this->controller->Link(), $this->name, 'LinkForm', 'forTemplate'),
Controller::join_links($this->controller->Link(), $this->name, 'MediaForm', 'forTemplate')

In your ModelAdmin subclass:

public function EditorToolbar() {
return new ModelAdminHtmlEditorField_Toolbar($this, $this->name."/EditorToolbar");


Forum Moderator, 1391 Posts

18 September 2012 at 3:43am

What build of SilverStripe 3 are you using? Just tried to add a HTMLEditor in 3.0.2 (rc2 I think) and it seems to work fine there, uploading images and all...


Community Member, 344 Posts

21 September 2012 at 3:50am

I'm having this issue too.


Community Member, 25 Posts

24 October 2012 at 11:37am

I can also confirm this issue but it looks like 'SamTheJarvis' fix where you setup a new class in your code directory and update your model admin class fixes the issue. As a note, I only seem to get this issue when you 1, search for something in model admin and then go to add a link etc.

If I come in on new session, login, go to the model admin and then choose to add a link, seems to work just fine. So not sure what is happening but seems like maybe something is getting messed up in the routing.

Thanks Sam for a work around


Community Member, 344 Posts

24 October 2012 at 10:11pm

If I come in on new session, login, go to the model admin and then choose to add a link, seems to work just fine.

This is because you're working with the cached version of the HTMLEditorField from Pages in this moment. If you ?flush the ModelAdmin, a new cached version for ModelAdmin will be created and the link to MediaForm and LinkForm in ModelAdmin will fail.

BLU42 Media

Community Member, 71 Posts

16 November 2012 at 1:51pm

This patch worked for us too. Thanks for sharing it!!

Go to Top