From f99792e604d326732c163cd30a97af3be3f2da69 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Thu, 26 Apr 2018 17:06:20 -0400 Subject: [PATCH] make selects work with ng required --- awx/ui/client/lib/components/input/base.controller.js | 3 ++- awx/ui/client/lib/models/Application.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/lib/components/input/base.controller.js b/awx/ui/client/lib/components/input/base.controller.js index 75caad2f07..32fa30b458 100644 --- a/awx/ui/client/lib/components/input/base.controller.js +++ b/awx/ui/client/lib/components/input/base.controller.js @@ -49,7 +49,8 @@ function BaseInputController (strings) { scope.state._touched = true; } - if (scope.state._required && !scope.state._value && !scope.state._displayValue) { + if (scope.state._required && (!scope.state._value || !scope.state._value[0]) && + !scope.state._displayValue) { isValid = false; message = vm.strings.get('message.REQUIRED_INPUT_MISSING'); } else if (scope.state._validate) { diff --git a/awx/ui/client/lib/models/Application.js b/awx/ui/client/lib/models/Application.js index 1fa79a3661..2a364eb9e7 100644 --- a/awx/ui/client/lib/models/Application.js +++ b/awx/ui/client/lib/models/Application.js @@ -2,7 +2,7 @@ let Base; function createFormSchema (method, config) { function mungeSelectFromOptions (configObj, value) { - configObj.choices = [['', '']].concat(configObj.choices); + configObj.choices = [[null, '']].concat(configObj.choices); configObj._data = configObj.choices; configObj._exp = 'choice[1] for choice in state._data'; configObj._format = 'selectFromOptions';