DEV Community

Discussion on: Error in react forms

Collapse
 
arung86 profile image
Arun Kumar G

Can you be able to share sample code
may be in a codesandbox or codepen, so that others can look at the code and try to see if they can fix this bug
Have you posted in stackoverflow.com already?

Collapse
 
sandeep_ap profile image
sandeep akinapelli

import React, { Component } from 'react';
import {
Card, CardTitle, CardBody, CardHeader, CardFooter, Collapse,
Dropdown, DropdownItem, DropdownMenu, DropdownToggle, InputGroup,
Form, Input, Button, Row, Col, Label, ButtonGroup
} from 'reactstrap';
import { connect } from 'react-redux';
// import { Control, Form, Errors, actions } from 'react-redux-form';
import { withRouter } from "react-router-dom";

class QuestionHeaderModalForm extends Component {
constructor(props) {
super(props);
this.onSubmit = this.onSubmit.bind(this);
this.onCancel = this.onCancel.bind(this);
this.state = {
rsDropDownOpen:false,
item: {
name:"",
description:"",
isvendor:false,
isinternal:false,
isreference:false
}
};
this.toggleRSDropDown = this.toggleRSDropDown.bind(this)
}

toggleRSDropDown() {
this.setState({rsDropDownOpen: !this.state.rsDropDownOpen})
}

onSubmit(values) {
console.log('values in onsubmit are:' + JSON.stringify(values.desc));
// this.props.onSubmitInitiative(values)
}

onDelete(values) {
// this.props.onDelete(values)
}

onCancel() {
// this.props.history.push('/initiatives');
console.log('oncancel called')
}

render() {
let deleteButton;
if (this.props.initiative) {
deleteButton =


} else {
deleteButton =
}

const existingRSItems = this.props.reqSections.reqSections.map(function (rsItem, index) {
return (
{rsItem.name}
);
});

return (


Question header:


this.onSubmit(values)}>




Select Reqruirement Section


Existing
{existingRSItems}

+Create new






Name
// defaultValue={this.props.item.description}
/>


Description




{' '}



{' '} Internal




{' '} Vendor




{' '} Reference










);
}
}

export default withRouter(connect()(QuestionHeaderModalForm));

Collapse
 
sandeep_ap profile image
sandeep akinapelli

import React, { Component } from 'react';
import {
Card, CardTitle, CardBody, CardHeader, CardFooter, Collapse,
Dropdown, DropdownItem, DropdownMenu, DropdownToggle, InputGroup,
Form, Input, Button, Row, Col, Label, ButtonGroup
} from 'reactstrap';
import { connect } from 'react-redux';
// import { Control, Form, Errors, actions } from 'react-redux-form';
import { withRouter } from "react-router-dom";

class QuestionHeaderModalForm extends Component {
constructor(props) {
super(props);
this.onSubmit = this.onSubmit.bind(this);
this.onCancel = this.onCancel.bind(this);
this.state = {
rsDropDownOpen:false,
item: {
name:"",
description:"",
isvendor:false,
isinternal:false,
isreference:false
}
};
this.toggleRSDropDown = this.toggleRSDropDown.bind(this)
}

toggleRSDropDown() {
this.setState({rsDropDownOpen: !this.state.rsDropDownOpen})
}

onSubmit(values) {
console.log('values in onsubmit are:' + JSON.stringify(values.desc));
// this.props.onSubmitInitiative(values)
}

onDelete(values) {
// this.props.onDelete(values)
}

onCancel() {
// this.props.history.push('/initiatives');
console.log('oncancel called')
}

render() {
let deleteButton;
if (this.props.initiative) {
deleteButton =


} else {
deleteButton =
}

const existingRSItems = this.props.reqSections.reqSections.map(function (rsItem, index) {
return (
{rsItem.name}
);
});

return (


Question header:


this.onSubmit(values)}>




Select Reqruirement Section


Existing
{existingRSItems}

+Create new






Name
// defaultValue={this.props.item.description}
/>


Description




{' '}



{' '} Internal




{' '} Vendor




{' '} Reference










);
}
}

export default withRouter(connect()(QuestionHeaderModalForm));