Updating date input type to allow empty dates
This commit is contained in:
@@ -17,7 +17,6 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
||||
<input type="hidden"
|
||||
[formControl]="formControl"
|
||||
[formlyAttributes]="field"
|
||||
[class.is-invalid]="showError"
|
||||
/>
|
||||
<div class="input-group" *ngIf="! this.field.props.readonly">
|
||||
<button class="btn btn-outline-secondary" (click)="d.toggle()" type="button"><i-bs name="calendar-date-fill"></i-bs></button>
|
||||
@@ -29,6 +28,7 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
||||
(ngModelChange)="changeDatetime($event)"
|
||||
ngbDatepicker
|
||||
#d="ngbDatepicker"
|
||||
[class.is-invalid]="showError"
|
||||
/>
|
||||
</div>
|
||||
<div class="input-group" *ngIf="this.field.props.readonly">
|
||||
@@ -49,6 +49,9 @@ export class DateTypeComponent extends FieldType<FieldTypeConfig> implements OnI
|
||||
ngOnInit() {
|
||||
if (this.formControl.value === undefined) {
|
||||
this.changeDatetime({});
|
||||
} else {
|
||||
this.datetime = new Date(this.formControl.value);
|
||||
this.date = this.getDateStruct(this.datetime);
|
||||
}
|
||||
|
||||
this.formControl.valueChanges.subscribe(value => {
|
||||
|
||||
@@ -14,7 +14,6 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
||||
<input type="hidden"
|
||||
[formControl]="formControl"
|
||||
[formlyAttributes]="field"
|
||||
[class.is-invalid]="showError"
|
||||
/>
|
||||
<div class="input-group" *ngIf="! this.field.props.readonly">
|
||||
<button class="btn btn-outline-secondary bi bi-calendar3" (click)="d.toggle()" type="button"></button>
|
||||
@@ -26,6 +25,7 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
|
||||
(ngModelChange)="changeDatetime($event)"
|
||||
ngbDatepicker
|
||||
#d="ngbDatepicker"
|
||||
[class.is-invalid]="showError"
|
||||
/>
|
||||
<ngb-timepicker
|
||||
(ngModelChange)="changeDatetime($event)"
|
||||
@@ -54,6 +54,9 @@ export class DatetimeTypeComponent extends FieldType<FieldTypeConfig> implements
|
||||
ngOnInit() {
|
||||
if (this.formControl.value === undefined) {
|
||||
this.changeDatetime({});
|
||||
} else {
|
||||
this.datetime = new Date(this.formControl.value);
|
||||
this.date = this.getDateStruct(this.datetime);
|
||||
}
|
||||
|
||||
this.formControl.valueChanges.subscribe(value => {
|
||||
|
||||
Reference in New Issue
Block a user