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.

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.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Coding a form in the CMS


Go to End


3 Posts   2184 Views

Avatar
bpesner

Community Member, 7 Posts

22 March 2009 at 4:08am

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.

Avatar
bpesner

Community Member, 7 Posts

22 March 2009 at 6:46am

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?

Avatar
bpesner

Community Member, 7 Posts

22 March 2009 at 2:29pm

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.