javascriptangularjsangular-formly

How do you disable a form input field using Angular Formly?


How do you disable a form input field using Angular Formly? I've googled and there is no clear cut answer. Indeed I have searched Formly's 'field configuration docs' and there is only one instance of the word 'disable' on that page, and it has nothing to do with actually disabling the field. Am I missing something?


Solution

  • By using the disabled option of templateOptions. Below is how I added this to one of my form fields:

    {
        key: 'accountNumber',
        type: 'input',
        templateOptions: {
            label: 'Account #',
            disabled: true,
            required: true
        }
    }