preston
preston

Reputation: 4337

How to disable entire redux form after submitting and then re-enable it after clearing all fields

What is the redux-form way of disabling the entire form upon submitting of values??

and how to re-enable the entire form upon clearing of all the values in the form field of the form??

I know the html way is via fieldset disable but I would like to know the redux-form way of doing these.

Upvotes: 1

Views: 582

Answers (1)

Erick
Erick

Reputation: 1146

When you click the submit button , update the store via dispatching an action and setting the value in the Reducer.Then use the updated value in the component.

constructor(props){ super(props); this.state={ enableForm:true
} this.handleSubmit=this.handleSubmit.bind(this) }

`componentWillRecieveProps(nextProps){
     if(this.props.status !== nextProps.status)
      {    this.setState({ enableForm:true })
      }
}`

handleOnSubmit() { this.setState({enableForm:false}) }

You can connect your store via connect from react-redux where you will get the value from the store via props. once you're value is set to false, you can perform a conditional rendering where the text Inputs are disabled.

Upvotes: 1

Related Questions