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.

1 Answers

0
Alex On

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.