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
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
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
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]");
Ah okay... Could you explain what the tags mean? Like why do some start with +, -, #, @, etc?
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...