This project is read-only.

Comments not working

Topics: Core
Oct 11, 2013 at 5:23 PM
Hi there,
I am using 1.7.1

I am trying to get comments to work fine for my project.

As it stands, a Anonymous user is able to enter a comment without validation kicking in.

In the CommentController, the Create method was creating a part before doing any checkings.
Right after, the method searches the ModelState for properties that do not exist. "Author, Email, etc" while they should be "Comments_Author, Comments_Email, etc".

Here is my revised code excerpt:
            var comment = Services.ContentManager.New<CommentPart>("Comment");

            dynamic editorShape = Services.ContentManager.UpdateEditor(comment, this);

            //if (!ModelState.IsValidField("Author")) {
            //    Services.Notifier.Error(T("Name is mandatory and must have less than 255 chars"));

            //if (!ModelState.IsValidField("Email")) {
            //    Services.Notifier.Error(T("Email is invalid or is longer than 255 chars"));

            //if (!ModelState.IsValidField("Site")) {
            //    Services.Notifier.Error(T("Site url is invalid or is longer than 255 chars"));

            //if (!ModelState.IsValidField("CommentText")) {
            //    Services.Notifier.Error(T("Comment is mandatory"));

            foreach (var error in ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage))
I just commented out the offending for clarity.
By Doing this, I get the comment to have some sort of validation, but it is far from what I am after.
The module also fails to validate when you Edit the Comment from the Admin. ValidationSummaries are in there, but i am not able to make it work.

I even taken the Comment creation into a diferent controller and decorated the new one with [theme] and another with [admin], but i have the same results.

How should i fix it, properly? Any ideas?

Thanks in advance