Is there any way to directly code a form in the CMS? When I try to do so, the CMS content editor removes my form and replaces it with a span tag. The forms I'm dealing with are very simple so I don't want to write php code to generate them. They post to a third party site, so I don't need/want any php code to deal with form submission. The forms each appear on only one page in the middle of the page content so I'd rather avoid having a bunch of special templates for them.
We've moved the forum!
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.
I've done some further investigation to see how the form elements are stripped out of the content. This seems to be handled by the tinyMCE WYSIWYG editor used in the CMS. This behavior is controlled by tinyMCE configuration values, which can be overridden in the CMS javascript source. I will play with doing this, but does anyone know if there are problems I may run into if I allow HTLM tags in my content that are currently being removed?
Here's how you can prevent the stripping of form elements from the CMS. It involves modifying the javascript file cms/javascript/tinymce.template.js. At line 43, modify the value for the valid_elements field to allow the tags you need. You can find the syntax at http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements.
This will allow the tags. However, there is still some logic somewhere that strips off some attributes, such as onsubmit for the form element. It's easy enough to get around this using javascript to assign the value at run time.
If anyone knows where the attribute stripping is happening, please let me know.