27

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>
Balázs
  • 2,919
  • 2
  • 16
  • 34
Pratish Shrestha
  • 1,382
  • 3
  • 15
  • 26

3 Answers3

47

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

You should insert your form inside an element <fieldset disabled="disabled">. This will make the whole form disabled.

Community
  • 1
  • 1
Mateus Zitelli
  • 1,092
  • 1
  • 12
  • 22
16

I had the same issue and this worked for me:

 <fieldset disabled={true}>

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

Bertus Kruger
  • 1,265
  • 1
  • 19
  • 30
-12

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

Manish62
  • 162
  • 1
  • 1
  • 13