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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[solved] Custom HTMLEditorField


Go to End


7 Posts   1918 Views

Avatar
Mo

Community Member, 541 Posts

2 September 2010 at 3:58am

Edited: 02/09/2010 4:08am

Hi All,

Just a quicky. I have a custom HTMLEditorField that I am loading into a form on a page. It is working pretty well and I have removed all but simple "bold","bullets" (etc) buttons.

I was wondering though, can I add custom CSS to this field? Maybe using HTMLEditorConfig? The default font is a little hard to read.

Currently the field is not loading editor.css, so I cant use that approach

Ideas?

Many thanks,

Mo

Avatar
Martijn

Community Member, 271 Posts

2 September 2010 at 4:02am

Something like this?:

$cfgContent = HtmlEditorConfig::get('someIdentifier');

$cfgContent->setOption('content_css', 'somefolder/css/editor.css');

Avatar
Mo

Community Member, 541 Posts

2 September 2010 at 4:08am

GENIUS!!

Now if I could only stop the bloody thing caching...

Thanks for your help.

Mo

Avatar
Martijn

Community Member, 271 Posts

2 September 2010 at 4:18am


Does this work?

$cfgContent->setOption('content_css', 'admintheme/css/editor.css?' .time());

Avatar
Mo

Community Member, 541 Posts

2 September 2010 at 5:06am

Ooo, Thats a good idea, why have I never thought of that?? ;)

Cheers,

Mo

Avatar
DeklinKelly

Community Member, 197 Posts

25 February 2011 at 10:45am

Any idea why this does not work? I get an error:

[User Error] Uncaught Exception: Object->__call(): the method 'setoption' does not exist on 'HtmlEditorField'

	$Content = new HTMLEditorField("Content", "Post", 20,75);
	$Content->setOption('content_css', 'themes/candy/css/editor.css');
	$fields = new FieldSet(
		new TextField("Title", "Title"),
		$Content,
		new CheckboxField("Agree", 'Agree?')
	);

Avatar
Invader_Zim

Community Member, 141 Posts

25 February 2011 at 12:18pm

Edited: 25/02/2011 12:18pm

Hi, setOption($k, $v) is a method of the HtmlEditorConfig class.
But you try to call it on an HtmlEditorField object (which totally doesn't know anything about it and is confused now ;-))

Cheers
Christian