Jump to:

1971 Posts in 1275 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » Coding a form in the CMS

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

Page: 1
Go to End
Author Topic: 1119 Views
  • bpesner
    Avatar
    Community Member
    7 Posts

    Coding a form in the CMS Link to this post

    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.

  • bpesner
    Avatar
    Community Member
    7 Posts

    Re: Coding a form in the CMS Link to this post

    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?

  • bpesner
    Avatar
    Community Member
    7 Posts

    Re: Coding a form in the CMS Link to this post

    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.

    1119 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.