32

I am disabling the inputs using the isFetching prop, but this is getting reduntant as I have to keep this in every input field. Is there a way to disable the entire form? Like a disable property in <form> tag or something?

<form>
  <input type="text" disabled={this.props.isFetching} />
  <input type="text" disabled={this.props.isFetching} />
</form>
0

3 Answers 3

59

I think this should solve your problem https://stackoverflow.com/a/17186342/3298693.

You should insert your a <fieldset disabled="disabled"> inside your form encapsulating the set of disabled fields.

1
  • 18
    Shouldn't it instead be "You should insert a <fieldset disabled="disabled"> element INSIDE your form"?
    – FMA
    Jun 19, 2018 at 12:45
20

I had the same issue and this worked for me:

 <fieldset disabled={true}>

Where true would be some "prop.setting"...

1
-16

Just use <input type="text" disabled> wherever you want the input text to be disabled. It hardly takes some time.

1
  • 6
    This is exactly what OP wants to avoid, as mentioned in the question.
    – Balázs
    Apr 23, 2017 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.