I have a requirement wherein I need to create fields dynamically through JSON. I have created my components as required and the page is rendered with required fields. But the fields are in non editable state, even though I had a onchange function in InputField js file. Following is the part of the code from my component
onChange(event) {
this.setState({
[event.target.name]: event.target.value
})
}
render() {
return (
this.props.screenField.fieldType === 'INPUT'
? <div className='form-group'>
<label htmlFor={this.props.screenField.name}>{this.props.screenField.label}:</label>
<input type={this.props.screenField.dataType === 'BOOLEAN'
? 'checkbox'
: this.props.screenField.dataType}
name={this.props.screenField.name}
id={this.props.screenField.name}
placeholder={this.props.screenField.helpText}
required={this.props.screenField.isRequired}
value={this.props.screenField.value} className='form-control'
onChange={this.onChange.bind(this)}/>
</div>
: null
)
}
Please find the URL below of the entire code.
https://github.com/yvsivateja/ReactJSApplications/tree/one/React-json-render