Using with Html Field

Sep 8, 2011 at 3:58 PM

CKEditor does not seem to automatically override the edtior template for Contrib.HtmlField part. For the CKEditor module in Body-Html.Editor.cshtml we have:

<script type="text/javascript">
//<![CDATA[
	CKEDITOR.replace('Body_Text',@Display.CKEditor_Config());
//]]>
</script>

Widgets that are using Contrib.HtmlField, have and id="<PartName>_Html_Text". CKEditor throws a Javascript error stating that the "Body_Text" element was not found.  

Am I missing a configuration item?

Thanks,

Matthew

Sep 11, 2011 at 7:40 PM
Edited Sep 11, 2011 at 8:27 PM

I am also having problems with this functionality.

Sep 11, 2011 at 9:00 PM
Edited Sep 11, 2011 at 9:00 PM

After some trial and error, I came up with this:

In my theme, I added the following file: (\Themes\MyTheme) \Views\EditorTemplates\Fields\Contrib.Html.cshtml

In this file I put this code:

 

@model Contrib.HtmlField.ViewModels.HtmlEditorViewModel
@using Orchard.Core.Common.ViewModels;
@using Orchard.Utility.Extensions;
<fieldset>
    <label>@Model.HtmlField.Name.CamelFriendly()</label>
    @Html.TextArea("Text", (string)Model.Text, 25, 80, new { @class = "html" })
    @Html.ValidationMessageFor(m => m.Text)
</fieldset>

@{
	Script.Require("CKEditor");
}
@using(Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
    CKEDITOR.replace("@Html.FieldIdFor(m => m.Text)");
//]]>
</script>
}
Coordinator
Oct 5, 2011 at 12:41 PM

I've fixed this in the latest commit. Thanks for letting me know!

Oct 5, 2011 at 12:44 PM

@randompete: No problem. Thank you for a great contribution.

@carruthersr: Your workaround helped me out in the meantime; I appreciate your help.