make selects work with ng required

This commit is contained in:
John Mitchell 2018-04-26 17:06:20 -04:00
parent 3bcc48402c
commit f99792e604
No known key found for this signature in database
GPG Key ID: FE6A9B5BD4EB5C94
2 changed files with 3 additions and 2 deletions

View File

@ -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) {

View File

@ -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';