-
Notifications
You must be signed in to change notification settings - Fork 31
Description
I have a form with a field in the form model that should not be changed by the user and is filled automatically for create forms.
I would still like to display this field to the user, but disable the input.
I tried the following, but the readOnlyProperty is still editable.
public baseForm = createForm<Entity, EntityFormModel>(this, { formType: FormType.ROOT, disabled$: this.disabled$, input$: this.input$, output$: this.updatedEntity, manualSave$: this.manualSave$, formControls: ChartFormComponent.getFormControls(), toFormGroup: (obj: Entity): EntityFormModel => { return mapEntityToEntityFormModel(obj); }, fromFormGroup: (formValue: EntityFormModel): EntityUnion => { return mapEntityFormModelToEntity(formValue); } });
private static getFormControls(): Controls<EntityFormModel> { return { // Should be disabled, but still shown to the user. readOnlyProperty: new FormControl({disabled: true}), discriminator: new FormControl(null), // Should and is editable. property: new FormControl(null) } }