Copied to clipboard

Flag this post as spam?

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


  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Apr 02, 2014 @ 15:35
    Dave Woestenborghs
    0

    Prevent prevalue editor from saving

    Hi,

    I'm creating a prevalue editor where the user can create a array of settings.

    If there is no entry in the array saving should not be possible.

    What I'm trying to do is this

    $scope.$on("formSubmitting", function (ev, args) {
                    if ($scope.myarray.length == 0) {
                        return false;
                    }
                });

    But I don't know how to cancel the submit and show a error message ? Anybody got an idea ?

    Or should I create a class implementing IPropertyValidator? But that seems overkill for such a simple check

    Dave

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Apr 02, 2014 @ 16:12
    Dave Woestenborghs
    1

    Hi,

    For those interested. I have found a solution for my problem, but it feels a bit hacky. But for now it does the trick.

    I have created a hidden in put filled that I marked as required :

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

    Then in my controller I change the value of this field when changing my array. If the array is empty, I clear the value of the hidden field. Now validation works for me.

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft