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.

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

HTMLEditorConfig - per Editor configuration - question from a humble n00b.

Go to End

10 Posts   5535 Views


Community Member, 5 Posts

18 August 2012 at 9:32am

Edited: 20/08/2012 12:37am

Mmh - Uncle Cheese's BootstrapForm Module rocks, but it did not help me with my problem...

Instead I have - ahem probably - succeded in adapting CustomConfigHtmlEditorField to my needs:

CustomHtmlEditorfield::create($DBObject, $Title, $NameOfExistingEditorConfig, $Value)

This gives you a HtmlEditorfield based on a configuration $NameOfExistingEditorConfig.
Edit: Above became obsolete, see below.

To the best of my knowledge, this might be a pretty bad hack: I haven't really figured out Entwine (which seems pretty cool) and the PHP/JavaScript Interactions in the backend yet and I am not a programmer.

Still, here's my code for CustomHtmlEditorfield. It might not be pretty but - for now - it works for me. Any criticism is very much appreciated. Maybe I just reinvented the wheel, but the advocated solutions did not work for me...

Edit: Did not work as expected after all - created multiple invisible TinyMCE instances :-(

New approach:

class CustomHtmlEditorField extends HtmlEditorField {
    protected $config = 'cms';
    public function __construct($name, $title = null, $value = '') {
		TextareaField::__construct($name, $title, $value);
    public function setConfig($config = 'cms') {
        $this->config = $config;
        return $this;
    function Field($properties = array()) {
        return parent::Field($properties);
    protected function include_customjs() {
                $configObj = HtmlEditorConfig::get($this->config);
                $configIdString = '_'.$this->config;

                Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
                            $.entwine('ss', function($) {
                                    redraw: function() {
                                        var config = ssTinyMceConfig$configIdString, self = this, ed = this.getEditor();
                                        self.css('visibility', '');
                                        ed.create(this.attr('id'), config, function() {
                                                self.css('visibility', 'visible');
                        ", 'htmlEditorConfig'.$configIdString);

Editor configurations are now loaded via


Well, i guess it's still a pretty crude hack :-)


Community Member, 3 Posts

11 March 2014 at 10:27am

Edited: 11/03/2014 10:39am

As a follow-up and as @mats found out, there is no way to have multiple HTMLEditorConfig's in SS 3.x out-of-the-box (As at March '14). Also, we shouldn't have to extend HTMLEditorField or HTMLEditorConfig to achieve this, so a core-patch will be required.

I needed some functionality almost identical to @matt and after a chat with Hamish, I came up with the following:

- Multiple HTMLConfig's defined in _config.php = check.
- No additional fields = check.
- Tested: Only FF and Chrome on OS X.
- To add own config:

1). Adapt/create your own config in your module's or mysite's _config.php file.
2). Apply the patch from the repo above
3). Add an extra boolean param to your HtmlEditorField construct call e.g.

new HtmlEditorField('MyField', 'My label', 3, 20, true);

4). Voila.


1). While this framework patch does work as far as switching between PageTypes with differing HTMLEditorConfig's set goes, there is a small JS glitch when swapping between them. If you switch from a Page with a custom config, back to a Page using the default config (This on a CWP SS 3.1 site) you'll notice that TinyMCE's default dropdown templates show for the <paragraph> and <heading> dropdowns. Simply reloading the page, "fixes" this.

2). This is untested in anything but Firefox and Chrome on OS X

I'm guessing some sort of editor JS redraw needs to be called, but not sure at this point what or where as yet.


Go to Top