File tree Expand file tree Collapse file tree 5 files changed +10
-1
lines changed
client-side/angular/packages/reactive-form-validators Expand file tree Collapse file tree 5 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,9 @@ export const defaultContainer:
130
130
propertyType : propertyType ,
131
131
entity : entity ,
132
132
dataPropertyName : config ? config . name : undefined ,
133
- entityProvider : config ? config . entityProvider : undefined
133
+ entityProvider : config ? config . entityProvider : undefined ,
134
+ defaultValue :config ? config . defaultValue : undefined ,
135
+ objectConfig :config && config . autoCreate ? { autoCreate :config . autoCreate } : undefined
134
136
}
135
137
defaultContainer . addProperty ( target . constructor , propertyInfo ) ;
136
138
}
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ export interface PropertyInfo {
33
33
ignore ?: ( x : any ) => boolean ;
34
34
isPrimaryKey ?: boolean ;
35
35
entityProvider ?: Function ;
36
+ objectConfig ?:{
37
+ autoCreate ?:boolean
38
+ }
36
39
arrayConfig ?: {
37
40
allowMaxIndex ?: number ;
38
41
messageKey ?: string ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export interface PropConfig {
7
7
8
8
export interface PropObjectConfig extends PropConfig {
9
9
entityProvider ?: Function ;
10
+ autoCreate ?:boolean ;
10
11
}
11
12
12
13
export interface PropArrayConfig extends PropObjectConfig {
Original file line number Diff line number Diff line change @@ -465,6 +465,9 @@ export class RxFormBuilder extends BaseFormBuilder {
465
465
break ;
466
466
case OBJECT_PROPERTY :
467
467
let objectValue = entityObject [ property . name ] ;
468
+ objectValue = ! objectValue && property . defaultValue ? property . defaultValue :objectValue
469
+ if ( ! objectValue && property . objectConfig && property . objectConfig . autoCreate )
470
+ objectValue = this . createClassObject ( property . entity , { } ) ;
468
471
if ( objectValue && objectValue instanceof Object && ! ( objectValue instanceof FormGroup || objectValue instanceof RxFormGroup ) ) {
469
472
this . isNestedBinding = this . isNested = true ;
470
473
if ( instanceContainer && instanceContainer . conditionalObjectProps )
You can’t perform that action at this time.
0 commit comments