Answer the question
In order to leave comments, you need to log in
How to set a "visibility" variable for a field in React?
There are Form components with inputs that are hidden under Panel, Collapse or immediately visible to the user. You need to specify all visible inputs as required for input.
Is it possible to do this somehow through a generic validation method? Something like a visibility variable and if true, then it is required for input. The difficulty is that there are about 900 inputs in the application ... How can I do this without creating 900 functions?
Answer the question
In order to leave comments, you need to log in
<form onSubmit={this.handleSubmitTest}>
//Мы задаем один и тот же стейт на открытие фрагмента формы и на required,
//соответственно если форма открыта, то и поле необходимо
<Input type="checkbox" onChange={()=>this.setState({check: !this.state.check})}/>
<Input type="text" placeholder="Enter UR Number" required={this.state.check}/>
<ButtonInput type="submit" value="Submit Button"/>
</form>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question