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

Getting TinyMCE to accept form tags?


Reply


4 Posts   2158 Views

Avatar
bkosborne

Community Member, 3 Posts

1 May 2010 at 8:14am

Hey everyone

I need TinyMCE to be able to accept form tags and all the standard HTML input tags. How can I do this? I noticed a lot of people have these issues but there doesn't seem to be a clear answer on the forums anywhere. Thanks

Brian

Avatar
Willr

Forum Moderator, 5513 Posts

1 May 2010 at 9:43pm

Edited: 01/05/2010 9:44pm

You can extend the allowed elements by defining your own HtmlEditorConfig option in your mysite/_config.php file. See the cms/_config.php for an example.

HtmlEditorConfig::get('cms')->setOption(
   'valid_elements' => "form[action],@[id|class|style|title],#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|style],-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|style],-pre[class|align],address[class|align],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class]");

Avatar
bkosborne

Community Member, 3 Posts

2 May 2010 at 3:28am

Ah okay... Could you explain what the tags mean? Like why do some start with +, -, #, @, etc?

Avatar
MattyJ

Community Member, 11 Posts

19 May 2010 at 12:28am

After hours of longdesc being stripped out of HTML editor every time, 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]");

You can probably alter this for forms I would imagine as it overrides the tinymce code. I've got to create a form later so I'll test it then.

TinyMCE should allow you to enter unfiltered HTML if you really want to. Not everyone has to worry about crazy site authors breaking code and creating security holes. There are hundreds of people wrestling with this issue right now around the globe and tinymce forum admins just flame anyone who questions it! Crazy...but other than that a nice little editor...