SaaS CMS has officially launched! Learn more now.

Required dataAnnotation prevent me creating a page instance, why model validation happens before page publish?

Vote:
 

I had a simple page type and has body property required as below, however when I created a new page from this page type via cms, first the "publish" button is gone, second, the local block didn't show up, it just kept showing me body is required. If I removed [Required] attribute, everything works fine.

I have checked the epsiode released by EPi server yesterday (http://www.episerver.com/About-Us/holidaycountdown2012/5-Validation-attributes-in-EPiServer-7/), it seems this epsiode only demonstrated for existing page instance not for new page instance.

The only workaround is to overwrite the SetDefaultValue method in my page type, but that's no a real solution I guess. can someone point me to the right direction?

page type

    [ContentType(GUID = "4f654133-7024-4a96-b469-80c5edee06e7")]
    public class StandardPage : PageData
    {
        [Display(
            GroupName = SystemTabNames.Content,
            Order = 310)]
        [CultureSpecific]
       [Required]
        public virtual XhtmlString MainBody { get; set; }

        [Display(
            GroupName = SystemTabNames.Content,
            Order = 320)]
        public virtual ContentArea MainContentArea { get; set; }

          [Display(
            GroupName = SystemTabNames.Content,
            Order = 330)]
        public virtual SimpleBlock SimpleBlock { get; set; }

    }

    

#64429
Dec 20, 2012 13:42
Vote:
 

Second issue is when applied Required attribute on the block type property, I dragged shared block into content area and filled the rest of fields but not that required field, after I clicked done, it still closed windows without showing me up the errors before I published the changes. 

#64441
Dec 20, 2012 14:02
Vote:
 

anyone encounter the same issue??

#64506
Dec 24, 2012 3:58
Vote:
 

 

Hello,

I believe that the first issue you described is how they meant it to work.

The editor is presented with the required fields only. Hence, the title "Enter the required information bellow". Before this is entered, the editor can't save and publish. I am not sure why this bothers you, perhaps you see the reason why this is a bad idea? I would just say it works differently than in previous EPi versions. This is the view I am seeing: http://img255.imageshack.us/img255/9681/enterrequiredcontent.jpg

As for the second issue, I could not reproduce this, I am getting the error and I can't save and publish new block that doesn't have a required field filled.

#64510
Dec 24, 2012 13:24
Vote:
 

Hi Marija

Thanks for your response. Maybe my initial post and page type didn't make quite sense and wasn't able to help you recreate the problem. Let me dive into more details to explain my problem.

This time I add more properties to my previous page type. In my page type (StandardPage), the 2nd and 3rd title properties are not required.

Firstly I used this page type to create a new page instance, in the edit mode, the 2nd and 3rd titles did not show in the editor which is very confused, check this screenshot http://i46.tinypic.com/2evcj0w.jpg.

Secondly, the whole cms editor css was broken (I can't see the done button at the bottom) because of this page type contains more properties now, that's why you can't reproduce this issue by using the initial post page type. 

Finally, after I created this page instance by hitting the "tab" key to get to "done" button, the 2nd and 3rd title reappeared.

 

 [ContentType(GUID = "4f654133-7024-4a96-b469-80c5edee06e7")]
    public class StandardPage : PageData
    {
        [Display(
    GroupName = SystemTabNames.Content,
    Order = 300)]
        [CultureSpecific]
        [Required]
        public virtual string Title { get; set; }

        [Display(
    GroupName = SystemTabNames.Content,
    Order = 301)]
        [CultureSpecific]
        public virtual string Title2 { get; set; }

        [Display(
    GroupName = SystemTabNames.Content,
    Order = 302)]
        [CultureSpecific]
        public virtual string Title3 { get; set; }

        [Display(
    GroupName = SystemTabNames.Content,
    Order = 303)]
        [CultureSpecific]
        [Required]
        public virtual string Title4 { get; set; }

        [Display(
    GroupName = SystemTabNames.Content,
    Order = 304)]
        [CultureSpecific]
        [Required]
        public virtual string Title5 { get; set; }

        [Display(
   GroupName = SystemTabNames.Content,
   Order = 305)]
        [CultureSpecific]
        [Required]
        public virtual string Title6 { get; set; }

        [Display(
            GroupName = SystemTabNames.Content,
            Order = 308)]
        [CultureSpecific]
        [Required]
        public virtual XhtmlString ShortDesc { get; set; }


        [Display(
            GroupName = SystemTabNames.Content,
            Order = 310)]
        [CultureSpecific]
        [Required]
        public virtual XhtmlString MainBody { get; set; }

        [Display(
            GroupName = SystemTabNames.Content,
            Order = 320)]
        public virtual ContentArea MainContentArea { get; set; }

        [Display(
          GroupName = SystemTabNames.Content,
          Order = 330)]
        public virtual SimpleBlock SimpleBlock { get; set; }

    }

    

#64540
Dec 29, 2012 17:46
Vote:
 

 

Hi, sorry for the long answer, I hope you fixed this in the meantime, but if not:

I believe this is a bug in IE.

I can reproduce it, but I could get to work:

Click on the MainBody and press tab a couple of times -> the button and the scroll bar will appear.

Perhaps this should be reported to EPi as a bug.

 

#64793
Edited, Jan 10, 2013 11:43
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.