File tree 2 files changed +35
-1
lines changed
directives/decorators/bootstrap
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1
- < div class ="form-group {{form.htmlClass}} schema-form-select "
1
+ < div ng-if =" form.allowAutoNullOption !== undefined " class ="form-group {{form.htmlClass}} schema-form-select "
2
2
ng-class ="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false} ">
3
3
< label class ="control-label " ng-show ="showTitle() ">
4
4
{{form.title}}
11
11
schema-validate ="form "
12
12
ng-options ="item.value as item.name group by item.group for item in form.titleMap "
13
13
name ="{{form.key.slice(-1)[0]}} ">
14
+ < option ng-if ="form.allowAutoNullOption !== false " value =""> {{form.allowAutoNullOption !== true ? form.allowAutoNullOption : ''}}</ option >
14
15
</ select >
15
16
< div class ="help-block " sf-message ="form.description "> </ div >
16
17
</ div >
18
+ < div ng-if ="form.allowAutoNullOption === undefined " class ="form-group {{form.htmlClass}} schema-form-select "
19
+ ng-class ="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false} ">
20
+ < label class ="control-label " ng-show ="showTitle() ">
21
+ {{form.title}}
22
+ </ label >
23
+ < select ng-model ="$$value$$ "
24
+ ng-model-options ="form.ngModelOptions "
25
+ ng-disabled ="form.readonly "
26
+ sf-changed ="form "
27
+ class ="form-control {{form.fieldHtmlClass}} "
28
+ schema-validate ="form "
29
+ ng-options ="item.value as item.name for item in form.titleMap "
30
+ name ="{{form.key.slice(-1)[0]}} ">
31
+ </ select >
32
+ < div class ="help-block "
33
+ ng-show ="(hasError() && errorMessage(schemaError())) || form.description "
34
+ ng-bind-html ="(hasError() && errorMessage(schemaError())) || form.description "> </ div >
35
+ </ div >
Original file line number Diff line number Diff line change @@ -359,6 +359,21 @@ angular.module('schemaForm').provider('schemaForm',
359
359
}
360
360
}
361
361
362
+ if ( obj . type === 'select' && obj . titleMap && obj . allowAutoNullOption !== false ) {
363
+ // when allowNull === false, we leave titleMap as it is.
364
+ // else we filter out the null value and setup allowNull to the label
365
+ // so the select template will behaviour different according to it.
366
+ obj . titleMap = obj . titleMap . filter ( function ( item ) {
367
+ if ( item . value === null ) {
368
+ // so we have null value option, setup the label and make it always selectable.
369
+ if ( obj . allowAutoNullOption === undefined )
370
+ obj . allowAutoNullOption = item . name === null ? '' : item . name ;
371
+ return false ;
372
+ }
373
+ return true ;
374
+ } ) ;
375
+ }
376
+
362
377
// Are we inheriting readonly?
363
378
if ( readonly === true ) { // Inheriting false is not cool.
364
379
obj . readonly = true ;
You can’t perform that action at this time.
0 commit comments