guillotinaweb / ngx-schema-form

HTML form generation based on JSON Schema
MIT License
485 stars 174 forks source link

Use DisableControlDirective for widgets to remove warnings for reactive forms. #441

Closed KBroichhausen closed 2 years ago

KBroichhausen commented 2 years ago

In dev mode there is the famous warning about reactive forms and disable attribute

  It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
  when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
  you. We recommend using this approach to avoid 'changed after checked' errors.

  Example:
  form = new FormGroup({
    first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
    last: new FormControl('Drew', Validators.required)
  });

I changed the widgets to use the already existing DisableControlDirective. The select widget had both methods: Attribute and via directive therefore I removed the attribute method.