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, biapar, Willr, Ingo, swaiba, simon_w

Where is valid_elements for TinyMCE in 2.3.1?

Go to End

11 Posts   5049 Views


3 June 2009 at 6:42am Community Member, 2 Posts

Need to try to allow some javascript functions to be put into the HTML view of TinyMCE without getting stripped out. Everything I am seeing is for older versions mainly changing the valid_elements located here:


It is obviously different in 2.3.1

Specifically, I am trying to do a simple url selector drop down with an OnChange that opens the selected url in a new window.

Any help greatly appreciated!



16 June 2009 at 6:15am Community Member, 24 Posts

Did you find the new settings file for TinyMCE?

i also wanted to modify tinymce.template.js because site search doesn't work with special characters transformed to html entities.
i need to change encoding to: entity_encoding : "raw"
see: [url=][/url]

using SS 2.3.2 rc2


16 June 2009 at 11:09pm Community Member, 24 Posts

allright i finally found it - you can now modify tinymce config in php

look at:

and look at (was much more helpful for me):
there the settings for tiny in the main tab are put together, around line 158 and following

now i simply put this in my _config.php:


4 August 2009 at 4:31am Community Member, 121 Posts


I have managed to change the valid elements in my /leftandmain.php file but when I tried to change the settings in my config.php file nothing was changing. I was changing the settings so I could put form elements in and then insert paypal buttons, I adjusted the equation the same way in both files but silverstripe only recognized the changes when they were made in leftandmain.php .

Here is the code I used perhaps someone can see an error I missed?

HtmlEditorConfig::get('cms')->setOption('valid_elements', '+form[method|action|target],+input[border|type|alt|name|src|value],+a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],-td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align|style],-span[class|align],-pre[class|align],address[class|align],-h1[id|dir|class|align],-h2[id|dir|class|align],-h3[id|dir|class|align],-h4[id|dir|class|align],-h5[id|dir|class|align],-h6[id|dir|class|align],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir]');

Thanks for any suggestions.



4 August 2009 at 9:45am (Last edited: 4 August 2009 10:01am), Community Member, 181 Posts

Hi Will,

I'm trying to get this working properly myself, I've read up on TinyMCE and tried to figure out what I can from the code.

You might want to try extended_valid_elements instead of valid elements.

I have a couple of sites deployed on SS2.3.0 and this used the old method, what I did find on this version was that SS has a callback function which strips out a whole bunch of other stuff (like all on* attributes!) regardless of how you configure TinyMCE, I have yet to find if this is being done in the latest implementation of TinyMCE on SS (although callback is deprecated in the latest version of TinyMCE)

Let us know how you get on, I'll be taking another look at this soon.



Perhaps I should have taken a quick look at the code again before posting this. In SSv2.3.2 the cleanup callback function is still being used. As much as I hate to edit core files I will be removing 'cleanup_callback' => "sapphiremce_cleanup" from LeftAndMain and anywhere else I find it. unless I can override this in _config.php

Just noticed Will that you are using SetOption instead of setOptions


7 August 2009 at 9:44am (Last edited: 7 August 2009 9:44am), Community Member, 121 Posts


Thanks for the quick reply. I tried both setoption with one element and setoptions with an array and no luck. I also tried the same with extended_valid_elements and none of these worked. You can see the methods I tried below. Anyway I still have it working by editing leftandmain.php but would be nice not to have to go into source files and be able to do it either from config.php or perhaps a class extension in the /code diterectory but not sure how this would be possible.

HtmlEditorConfig::get('cms')->setOption('valid_elements', '+form[method|action|target],

HtmlEditorConfig::get('cms')->setOptions(array('valid_elements' => "+form[method|action|target],

HtmlEditorConfig::get('cms')->setOptions(array('extended_valid_elements' => "+form[method|action|target],

HtmlEditorConfig::get('cms')->setOption('extended_valid_elements' , "+form[method|action|target],




29 October 2009 at 3:07am (Last edited: 29 October 2009 3:07am), Community Member, 224 Posts

Did anyone ever get this figured out? I want to include an form into my page, but it get stripped out. I have tried all what was mentioned already without success. Please help.


19 May 2010 at 12:19am Community Member, 11 Posts

After hours of longdesc being stripped out of HTML editor I found this line entered into mysite/_config.php to work in 2.3.7:

HtmlEditorConfig::get('cms')->setOption('extended_valid_elements' ,"+img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align]");

Hope this helps someone.

Go to Top