Jump to:

23374 Posts in 18175 Topics by 2866 members

General Questions

SilverStripe Forums » General Questions » [solved] Custom HTMLEditorField

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

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

Page: 1
Go to End
Author Topic: 1356 Views
  • Mo
    Avatar
    Community Member
    505 Posts

    [solved] Custom HTMLEditorField Link to this post

    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

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: [solved] Custom HTMLEditorField Link to this post

    Something like this?:

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

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

  • Mo
    Avatar
    Community Member
    505 Posts

    Re: [solved] Custom HTMLEditorField Link to this post

    GENIUS!!

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

    Thanks for your help.

    Mo

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: [solved] Custom HTMLEditorField Link to this post

    Does this work?

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

  • Mo
    Avatar
    Community Member
    505 Posts

    Re: [solved] Custom HTMLEditorField Link to this post

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

    Cheers,

    Mo

  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Re: [solved] Custom HTMLEditorField Link to this post

    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?')
       );

       

  • Invader_Zim
    Avatar
    Community Member
    141 Posts

    Re: [solved] Custom HTMLEditorField Link to this post

    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

    1356 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.