Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Funka! 398 posts 661 karma points
    Feb 18, 2012 @ 03:48
    Funka!
    0

    "Mandatory" properties not so mandatory after all...

    Note, this is problem we found on v4.7.1...

    We have found that our users can do the following:

    1. Completely ignore a "mandatory" property while editing a node and leave it blank. They click the "save" button anyway, and are told "your data has been saved, but before you can publish this page there are some errors that you need to fix first." (i.e., the mandatory property!)

    2. So, what do our users do? They simply right-click on a parent node, and choose "Publish", check a few boxes, et voila! Their bogus node with blank property has been published!  And then of course that section of the site crashes. And so then our users are confused and call us. We have to explain that the word "mandatory" actually means "required", and no, they are not supposed to find a way to leave this blank and should really fill in an expected value.

    We are currently hacking in some really quick-n-dirty javascript to not let you even save the node if any of the mandatory properties are left blank. I'm not sure if this is a problem in v5 but I hope this is something that can be addressed somehow.... Even if all you have to do is hack in some other just-as-cruddy javascript to prevent such a situation!

    Thx!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 18, 2012 @ 13:31
    Jeroen Breuer
    0

    I've also had this problem. Glad it seems to be solved in v5: http://our.umbraco.org/forum/core/umbraco-5-general-discussion/25082-Alpha-2-Publish-node-and-all-its-subpages. Too bad v5 has a different problem with mandatory fields: http://issues.umbraco.org/issue/U5-60

    Jeroen

  • Huri Jin 1 post 21 karma points
    Jan 22, 2013 @ 11:41
    Huri Jin
    0

    I've solved this problem by hooking BeforePublish event.

    voidDocument_BeforePublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
    {
       
    var props = sender.GenericProperties;
       
    foreach (umbraco.cms.businesslogic.property.Property p in props)
       
    {
           
    if (p.PropertyType.Mandatory)
           
    {
                if (string.IsNullOrWhiteSpace(sender.getProperty(p.PropertyType.Alias).Value.ToString()))
                {
                    e.Cancel=true;
                }
           
    }
        }
    }

    For more information about how to use BeforePublish event, see here: http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/event-examples

    Place the cs file in App_Code directory.

     

    Huri

Please Sign in or register to post replies

Write your reply to:

Draft