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

3.1 HTMLEditorField in front end form not sending data


Go to End


16 Posts   5795 Views

Avatar
Vix

Community Member, 60 Posts

23 January 2014 at 7:40pm

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?

Avatar
Vix

Community Member, 60 Posts

24 January 2014 at 8:50pm

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

Avatar
thomas.paulson

Community Member, 107 Posts

25 January 2014 at 12:35am

Edited: 25/01/2014 12:35am

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.

Avatar
Vix

Community Member, 60 Posts

28 January 2014 at 8:12pm

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.

Avatar
thomas.paulson

Community Member, 107 Posts

28 January 2014 at 8:52pm

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

Avatar
Vix

Community Member, 60 Posts

29 January 2014 at 3:35pm

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.

Avatar
thomas.paulson

Community Member, 107 Posts

29 January 2014 at 5:38pm

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

Avatar
Stefdv

Community Member, 110 Posts

12 February 2014 at 9:50am

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 ?

Go to Top