31

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,929
  • 2
  • 19
  • 34
Pratish Shrestha
  • 1,712
  • 4
  • 17
  • 26

3 Answers3

58

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,222
  • 1
  • 13
  • 23
19

I had the same issue and this worked for me:

 <fieldset disabled={true}>

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

Bertus Kruger
  • 1,345
  • 1
  • 19
  • 31
-15

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

Manish62
  • 154
  • 1
  • 1
  • 13