3066 Posts in 866 Topics by 648 members
| Go to End | Next > | |
| Author | Topic: | 1194 Views |
-
SilverStripe 3.0. ModelAdmin and HTMLEditor

27 June 2012 at 9:53pm
Hi,
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 classHow can use HTML editor field in ModelAdmin?
example:
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'
);
}
Thanks -
Re: SilverStripe 3.0. ModelAdmin and HTMLEditor

5 September 2012 at 2:57am
I'm also having this issue. Were you able to figure anything out?
-
Re: SilverStripe 3.0. ModelAdmin and HTMLEditor

17 September 2012 at 11:24pm Last edited: 18 September 2012 12:29am
Yep, definitely an issue.
http://logs.simon.geek.nz/index.php?date=2012-09-14
http://logs.simon.geek.nz/index.php?date=2012-07-04This 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");
} -
Re: SilverStripe 3.0. ModelAdmin and HTMLEditor

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...
-
Re: SilverStripe 3.0. ModelAdmin and HTMLEditor

21 September 2012 at 3:50am
I'm having this issue too.
-
Re: SilverStripe 3.0. ModelAdmin and HTMLEditor

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
-
Re: SilverStripe 3.0. ModelAdmin and HTMLEditor

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.
-
Re: SilverStripe 3.0. ModelAdmin and HTMLEditor

16 November 2012 at 1:51pm
This patch worked for us too. Thanks for sharing it!!
| 1194 Views | ||
| Go to Top | Next > |




