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.

Form Questions

HTMLEditorField not working as expected on frontend form


5 Posts   1366 Views

Dr. J

23 September 2012 at 11:05pm (Last edited: 1 October 2012 11:40am), Community Member, 8 Posts

I am trying to create a frontend form containing an HTMLEditorField. I have set up the form fields as below

$description = new HtmlEditorField('Description');
$fields = new FieldList(new TextField('Title', 'Job Title'),
                  new TextField('JobType','Type'),
                  new DateField('ClosingDate','Closing Date'),
                  new TextField('Reference'),
                  new TextField('ContactName','Contact'),
                  new EmailField('ContactEmail','Email'),

and created the database table for the corresponding DataObject to include a corresponding HTMLText field

class JobVacancy extends DataObject
static $db = array(
      'Title' => 'Text',
      'JobType' => 'Text',
      'ClosingDate' => 'Date',
      'Reference' => 'Text',
      'ContactName' => 'Text',
      'ContactEmail' => 'Text',
      'Description' => 'HTMLText'

The form is rendered as expected in that it contains the description field as follows

<div id="Description" class="field htmleditor">
   <label class="left" for="Form_CreateVacancyForm_Description">Description</label>
   <div class="middleColumn">
      <textarea name="Description" value="" class="htmleditor" id="Form_CreateVacancyForm_Description" rows="10" cols="10" tinymce="true" style="width: 97%; height: 160px"></textarea>

and the entire form appears like the attached image.

I am expecting this type of field to behave on my frontend form exactly the same way it does when I use this type of field on a tab in the CMS, consequently I have two problems:

Problem 1: On submission, the record is created but the content of the HTMLText field is the same as the text entered in the form, that is plain text rather than the expected HTML markup. If I include markup directly to the field the record contains the markup I entered. Is this expected behaviour?

Problem 2: There is no TinyMCE toolbar visible. Do I need to configure the page to display this? Is the absence of the TinyMCE toolbar related to Problem 1?

I appreciate any assistance understanding and hopefully resolving this issue.


Attached Files

30 September 2012 at 6:33pm Forum Moderator, 5511 Posts

Is the TinyMCE javascript loaded on the page or do you get a javascript error preventing it from loading?

Dr. J

1 October 2012 at 1:58pm Community Member, 8 Posts

Hi Willr

I am not getting any js errors when the pages loads and Firebug indicates that the scripts declared at the end of the page

<script type="text/javascript" src="/;plugins=contextmenu,table,emotions,paste,spellchecker&amp;themes=advanced&amp;diskcache=true&amp;src=false"></script>
<script type="text/javascript" src="/"></script>
<script type="text/javascript" src="/"></script>
<script type="text/javascript" src="/"></script>
<script type="text/javascript">//<![CDATA[
if((typeof tinyMCE != 'undefined')) {
var ssTinyMceConfig = {"friendly_name":"(Please set a friendly name for this config)","priority":0,"mode":"specific_textareas","editor_selector":"htmleditor","width":"100%","auto_resize":false,"theme":"advanced","theme_advanced_layout_manager":"SimpleLayout","theme_advanced_toolbar_location":"top","theme_advanced_toolbar_align":"left","theme_advanced_toolbar_parent":"right","blockquote_clear_tag":"p","table_inline_editing":true,"safari_warning":false,"relative_urls":true,"verify_html":true,"plugins":"contextmenu,table,emotions,paste,spellchecker","theme_advanced_buttons1":"bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,formatselect,separator,bullist,numlist,outdent,indent,blockquote,hr,charmap","theme_advanced_buttons2":"undo,redo,separator,cut,copy,paste,pastetext,pasteword,spellchecker,separator,advcode,search,replace,selectall,visualaid,separator,tablecontrols","theme_advanced_buttons3":""};

are loading correctly.

I am not explicitly setting configuration for the HTMLEditorField as I felt that the default would be sufficient to add the 'basics'. Could this be contributing to the behaviour I am seeing?


1 October 2012 at 7:20pm Forum Moderator, 5511 Posts

Perhaps related to

Dr. J

20 October 2012 at 3:21am (Last edited: 23 October 2012 2:33am), Community Member, 8 Posts

... but definitely related to this: [url=]HTMLEditor Field in frontend (SS3)[/url]