body part not updating

Topics: Troubleshooting, Writing modules
Apr 23, 2012 at 5:17 PM

I have a custom page that allows users to edit content:

@using (Html.BeginFormAntiForgeryPost())
{
        @Html.Partial("SaveButton");
        @Display(Model)
        
@Html.Partial("SaveButton"); if (Request.QueryString["id"] != null) { @Html.Hidden("id", int.Parse(Request.QueryString["id"].ToString())); } }

It loads the existing record fine and my post action:

        [HttpPost, ActionName("Index")]
        public ActionResult Edit(int? id)
        {
            ContentItem content = new ContentItem();
            if (id.HasValue)
            {
                content = _contentManager.Get((int)id, VersionOptions.Latest);
                var model = _contentManager.UpdateEditor(content, this);
                if (!ModelState.IsValid)
                    return View(model);
            }
            else
            {
                string contentType = Request.QueryString["new"].ToString();
                CreatePOST(contentType, null, contentItem =>
                {
                    if (!contentItem.Has() && !contentItem.TypeDefinition.Settings.GetModel().Draftable)
                        _contentManager.Publish(contentItem);
                });
            }

            RedirectOrNotify();

            return View();
        }

The record is successfully updated except for the body part. It updates as expected in the admin, but it simply doesn't update on my custom page.

Another thing to mention that may be related is that the "Insert/Update Media" button does nothing when clicked (all other buttons are functioning). That button does work in the admin, so I know there is something not getting included in my custom page.

 

Any ideas? Thanks!

Coordinator
Apr 23, 2012 at 5:46 PM

Of course it never updates: you're never telling it to.

Apr 23, 2012 at 6:55 PM
Edited Apr 23, 2012 at 6:57 PM

huh? Its getting updated here:
var model = _contentManager.UpdateEditor(content, this);

and again, the title and other fields are getting updated. Its just the body part(tinymce) that isn't updating.I have checked the code in the core, and don't wee where my code is different so I must be missing something but not sure where to look.Thanks

Coordinator
Apr 23, 2012 at 7:12 PM

That will only take care of parts by calling into handlers and drivers. Seeing that you gave pretty much no information whatsoever about the rest of the code you're using or why you need a custom action in the first place, it's almost impossible to guess what's going wrong here.

Apr 23, 2012 at 10:04 PM

Not sure if I am mis-reading your responses, but they seem a little rude. Having said that, I do completly appreciate any help provided by you or any other members. Orchard is a phenomenal system and I am extremely impressed by its design and implementation.

I think I posted enough code to explain the problem and I didn't want to post all 300+ lines because this was the only code relevant to my problem.

Anyway, my problem was that the bodypart posts html content, so once I drilled into the code I discovered that this error was being thrown:

{"A potentially dangerous Request.Form value was detected from the client (Body.Text=\"<p>my content here</p>\")."}

So after simply adding [ValidateInput(false)] as an attribue to my controller class, the problem was resolved.

Hope that helps someone else having the same problem.

Coordinator
Apr 23, 2012 at 11:25 PM

Really? What did I say that sounded rude to you?