2

I have an antd form with multiple form items and try to find a way to mark the complete form as readonly. I could for sure set each input component to 'disabled' but I wonder if there is a convenient way to do so on the form via an API call that I do not know yet.

Rallen
  • 2,060
  • 18
  • 21
gibelium
  • 91
  • 6

2 Answers2

3

Wrapping the antd form inside a fieldset and setting this to 'disabled' works pretty well.

<fieldset disabled={editorDisabled}>
  <Form>
    ...
  <Form/>
<fieldset/>
gibelium
  • 91
  • 6
1

I don't see such an option in the form api, and I think it's the rare use case, so I doubt it exists. However, you can simply add variable which will track the disabled status, i.e.:

const YourAwesomeComponent = (props) => {
     const disabled = someLogicToCalculateTheDisabledStatus(props);
     return <Form ...>
         <Input disabled={disabled} ... />
         <Select disabled={disabled} ... />
         <Button disabled={disabled} ... />
     </Form>
}

Hope it helps.

Alesj
  • 5,581
  • 1
  • 16
  • 33