Copied to clipboard

Flag this post as spam?

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


  • Chris Evans 137 posts 353 karma points c-trib
    Feb 02, 2014 @ 19:17
    Chris Evans
    1

    Umbraco 7 property editor - custom validation, prevent Publish

    Hi all,

    I'm trying to find a way to prevent the Publish action from happening on a custom property editor in Umbraco 7, when there is a validation condition set.

    e.g. in my angular controller i've got a simple global boolean for hasError - when that is true, I don't want the user to be able to Publish the page but rather want a validation message to show if they hit Publish.

    There doesn't seem to be anything in the official documentation about how to do this, or at least I haven't found it.

    Is there an event we can subscribe to in the JS and return false, or call a preventDefault or stopPropagation on, in order to stop the Publish action from happening?

    Or some other method provided by the umbraco angular framework we should be using.

    Any help appreciated!

  • Christian Lübeck 2 posts 22 karma points
    Jun 18, 2014 @ 12:43
    Christian Lübeck
    0

    Hi Chris,

    have you ever found a solution for this problem? Facing the exact same issue.

    Thanks,

    Christian

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Jun 18, 2014 @ 12:50
    Dave Woestenborghs
    3

    I have done it this way.

    I created a hidden field with a required attribute.

    <input type="hidden" name="IsValid" ng-model="IsValid" required />

    Then in my angular controller I have function that I call that fills this field when my editor is valid. If it's not valid I leave it empty.

     $scope.IsValidModel= function() {
                    if (yourvalue != valid) {
                        $scope.IsValid= "";                    
                    } else {
                        $scope.IsValid= "valid";                    
                    }
                }

    That should do the trick

    Dave

  • mcgrph 35 posts 162 karma points
    Apr 30, 2019 @ 10:35
    mcgrph
    0

    Nice! That did it for me

  • George 32 posts 65 karma points
    Aug 11, 2020 @ 10:08
    George
    0

    Great solution! Thanks for posting!

Please Sign in or register to post replies

Write your reply to:

Draft