问题
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>
回答1:
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.
回答2:
I had the same issue and this worked for me:
<fieldset disabled={true}>
Where true would be some "prop.setting"...
回答3:
Just use <input type="text" disabled> wherever you want the input text to be disabled. It hardly takes some time.
来源:https://stackoverflow.com/questions/36215244/disable-entire-form-elements-with-respect-to-a-state-react