Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » 3.1 HTMLEditorField in front end form not sending data

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

Page: 1 2
Go to End
Author Topic: 1312 Views
  • Vix
    Avatar
    Community Member
    25 Posts

    3.1 HTMLEditorField in front end form not sending data Link to this post

    I have a form on the front end of my site that contains some HTMLEditorFields. In order to get these to work I had to add the following to my template;

    <link rel="stylesheet" href="framework/thirdparty/tinymce/themes/advanced/skins/default/ui.css">
    <script type="text/javascript" src="framework/thirdparty/tinymce/tiny_mce_gzip.php?m=1378998164&amp;js=1&amp;plugins=contextmenu,table,emotions,paste,spellchecker,media,fullscreen,inlinepopups&amp;themes=advanced&amp;languages=en&amp;diskcache=true&amp;src=false"></script>
    <script type="text/javascript" src="framework/javascript/HtmlEditorField.js?m=1378998161"></script>
    <script type="text/javascript">      
          tinyMCE.init({
          theme : "advanced",
          mode: "textareas",
          theme_advanced_toolbar_location : "top",
          theme_advanced_buttons1 : "formatselect,|,bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,separator,undo,redo",
          theme_advanced_buttons2 : "",
          theme_advanced_buttons3 : "",
          height:"250px",
          width:"552px"
          });
       </script>

    This has allowed the text editor to show up, but when the form is submitted the two textarea fields data does not get sent. If I remove the wysiwyg editor and have plain textareas the data is passed no problem.

    Does anyone know if there is something else I need to include to make it function properly? Or if there is a better way to get a HTMLEditorField to work on a front end form?

  • Vix
    Avatar
    Community Member
    25 Posts

    Re: 3.1 HTMLEditorField in front end form not sending data Link to this post

    Am I doing something wrong in this forum? No one ever replies to anything I post.

  • thomas.paulson
    Avatar
    Community Member
    72 Posts

    Re: 3.1 HTMLEditorField in front end form not sending data Link to this post

    try

    <?php
    ///
    class FrontendHtmlEditorField extends HtmlEditorField {

    public function __construct($name, $title = null, $value = '') {
    parent::__construct($name, $title, $value);
    self::include_js();
    }

    public static function include_js() {
    parent::include_js();
    Requirements::customScript("ssTinyMceConfig.editor_selector='frontendhtmleditor';tinyMCE.init(ssTinyMceConfig);");
    }
    }

    and replace with below code in Form.
    $contentfield = new FrontendHtmlEditorField('Content', _t("ContentEntry.CN",'Content'));

    hope it works.

  • Vix
    Avatar
    Community Member
    25 Posts

    Re: 3.1 HTMLEditorField in front end form not sending data Link to this post

    Thank you for your response, unfortunately it has not worked.

    The text editor still shows nicely, but the data does not pass on when submitted.

    I have just made my submit function print out what is in the $data array and the FrontendHtmlEditorField still shows as being empty, but if I make it just a textarea field then it passes the data no problem.

  • thomas.paulson
    Avatar
    Community Member
    72 Posts

    Re: 3.1 HTMLEditorField in front end form not sending data Link to this post

    Do you mind sharing the url, you can email me.

  • Vix
    Avatar
    Community Member
    25 Posts

    Re: 3.1 HTMLEditorField in front end form not sending data Link to this post

    It is http://ozzy.perthwebdev.com.au/create-an-account/create-a-post and if you select the 'Investors page listing'.

    I have left it with just displaying the $data array after it is submitted.

    Thank you for your help.

  • thomas.paulson
    Avatar
    Community Member
    72 Posts

    Re: 3.1 HTMLEditorField in front end form not sending data Link to this post

    Hello Vix

    It looks like the visibility of the htmleditor textarea is hidden.

    visibility:hidden;

    I have to look at the code, to see what is wrong. you can skype me thomas.paulson28

  • Stefdv
    Avatar
    Community Member
    110 Posts

    Re: 3.1 HTMLEditorField in front end form not sending data Link to this post

    Hi there,

    any progress on this? I searched everywhere but cannot find a post that fully describes how i can add a htmleditor field in the frontend...
    I'm using SS3.1

    As far as i understand the simpleHtmleditorfield from dataobjectmanager is no longer working in ss3 ?

    1312 Views
Page: 1 2
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.