I'm developing custom News module for Orchard CMS. My NewsItem
consists of few parts: TitlePart
, CommonPart
, BodyPart
and my custom NewsPart
.
When I try to create and save item, BodyPart
becomes empty (other parts save correctly), and there is NULL
value in DB. If I change Text
column value in Common_BodyPartRecord
table and then open item in editing mode, editor is empty, no value is loaded.
here is a definition of my NewsItem
from migrations.cs
:
ContentDefinitionManager.AlterTypeDefinition("NewsItem", t => t
.WithPart("NewsPart")
.WithPart("CommonPart", p => p.WithSetting("DateEditorSettings.ShowDateEditor", "true"))
.WithPart("TitlePart")
.WithPart("BodyPart")
.Draftable()
);
I've tried to debug BodyPartDriver
class. When I load news item editor in admin UI, Editor()
method has input BodyPart part
parameter. this is the instance of BodyPart
attached to my NewsItem
. And here part.Text
is empty string. But part.base.Record.Text = "Test"
as I set in DB table directly.
I can't understand what is wrong here. Other parts like TitlePart
or my NewsPart
are working fine. I do not have custom code with this BodyPart
in my module. Seems I missed something, but what exactly?
In addition. There is an exception in Orchard Error log:
2014-10-22 17:25:15,307 [19] Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCoordinator -
Default - HttpRequestValidationException thrown from IContentPartDriver by
Orchard.Core.Common.Drivers.BodyPartDriver
http://localhost:30321/OrchardLocal/Admin/News/Edit/56
System.Web.HttpRequestValidationException (0x80004005): A potentially dangerous
Request.Form value was detected from the client (Body.Text="<p>123123123</p>").
PS: I've added [ValidateInput(false)]
attribute to my NewsAdminController
class as in default Orchard.Core.Contents.Controllers.AdminController
. And now BodyPart
saves correctly. But seems to me it is not the right way.