diff --git a/awx/ui/client/src/shared/directives.js b/awx/ui/client/src/shared/directives.js index 0255aaee8b..3531e78f0b 100644 --- a/awx/ui/client/src/shared/directives.js +++ b/awx/ui/client/src/shared/directives.js @@ -1371,4 +1371,33 @@ function(ConfigurationUtils, i18n, $rootScope) { }); } }; +}]) + +.directive('awRequireMultiple', [function() { + return { + require: 'ngModel', + link: function postLink(scope, element, attrs, ngModel) { + // Watch for changes to the required attribute + attrs.$observe('required', function(value) { + if(value) { + ngModel.$validators.required = function (value) { + if(angular.isArray(value)) { + if(value.length === 0) { + return false; + } + else { + return (!value[0] || value[0] === "") ? false : true; + } + } + else { + return false; + } + }; + } + else { + delete ngModel.$validators.required; + } + }); + } + }; }]); diff --git a/awx/ui/client/src/templates/survey-maker/render/multiple-choice.partial.html b/awx/ui/client/src/templates/survey-maker/render/multiple-choice.partial.html index 580c8e5805..7fa7e1fa0d 100644 --- a/awx/ui/client/src/templates/survey-maker/render/multiple-choice.partial.html +++ b/awx/ui/client/src/templates/survey-maker/render/multiple-choice.partial.html @@ -1,5 +1,5 @@
-