@@ -624,7 +624,8 @@ var fng;
624
624
var allInputsVars = formMarkupHelper . allInputsVars ( scope , fieldInfo , options , modelString , idString , nameString ) ;
625
625
var common = allInputsVars . common ;
626
626
var value ;
627
- var requiredStr = ( isRequired || fieldInfo . required ) ? ' required' : '' ;
627
+ isRequired = isRequired || fieldInfo . required ;
628
+ var requiredStr = isRequired ? ' required' : '' ;
628
629
var enumInstruction ;
629
630
switch ( fieldInfo . type ) {
630
631
case 'select' :
@@ -635,7 +636,14 @@ var fng;
635
636
common += ( fieldInfo . readonly ? 'disabled ' : '' ) ;
636
637
common += fieldInfo . add ? ( ' ' + fieldInfo . add + ' ' ) : '' ;
637
638
value = '<select ' + common + 'class="' + allInputsVars . formControl . trim ( ) + allInputsVars . compactClass + allInputsVars . sizeClassBS2 + '" ' + requiredStr + '>' ;
638
- if ( ! isRequired ) {
639
+ if ( isRequired ) {
640
+ /*
641
+ Tell the user to select a value
642
+ This becomes disabled in updateRecordWithLookupValues (setting disabled now causes $pristine to be unset, which conflicts with the condition in updateRecordWithLookupValues)
643
+ */
644
+ value += '<option class="disableMe" value="">Select a value</option>' ;
645
+ }
646
+ else {
639
647
value += '<option></option>' ;
640
648
}
641
649
if ( angular . isArray ( fieldInfo . options ) ) {
@@ -2709,6 +2717,9 @@ var fng;
2709
2717
if ( newVal ) {
2710
2718
setData ( $scope . record , schemaElement . name , undefined , newVal ) ;
2711
2719
}
2720
+ if ( schemaElement . required ) {
2721
+ angular . element ( '#' + schemaElement . id + ' .disableMe' ) . prop ( 'disabled' , true ) ;
2722
+ }
2712
2723
}
2713
2724
} ;
2714
2725
// Split a field name into the next level and all following levels
@@ -2781,11 +2792,14 @@ var fng;
2781
2792
}
2782
2793
var simpleArrayNeedsX = function ( aSchema ) {
2783
2794
var result = false ;
2784
- if ( ! aSchema . directive ) {
2795
+ if ( aSchema . needsX ) {
2796
+ result = true ;
2797
+ }
2798
+ else if ( ! aSchema . directive ) {
2785
2799
if ( aSchema . type === 'text' ) {
2786
2800
result = true ;
2787
2801
}
2788
- else if ( aSchema . needsX || ( ( aSchema . type === 'select' ) && ! aSchema . ids ) ) {
2802
+ else if ( aSchema . type === 'select' && ! aSchema . ids ) {
2789
2803
result = true ;
2790
2804
}
2791
2805
}
0 commit comments