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

SilverStripe 3.0. ModelAdmin and HTMLEditor

Go to End

10 Posts   2429 Views


27 June 2012 at 9:53pm Community Member, 2 Posts

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'



5 September 2012 at 2:57am Community Member, 1 Post

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


17 September 2012 at 11:24pm (Last edited: 18 September 2012 12:29am), Community Member, 24 Posts

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


18 September 2012 at 3:43am Forum Moderator, 1091 Posts

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...


21 September 2012 at 3:50am Community Member, 215 Posts

I'm having this issue too.


24 October 2012 at 11:37am Community Member, 24 Posts

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


24 October 2012 at 10:11pm Community Member, 215 Posts

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

16 November 2012 at 1:51pm Community Member, 71 Posts

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

Go to Top