Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
197 views
in Technique[技术] by (71.8m points)

javascript - ReduxForm数据在表单加载时初始(ReduxForm data initial on Load of Form)

Using redux I created a form and I am able to dispatch actions, validations and is working fine without any issues.

(使用redux,我创建了一个表单,并且能够调度动作,验证,并且工作正常,没有任何问题。)

But load data/initialize on to form field(ReduxForm) not populating data but code executed, can anyone help me in fixing the issues or where I am going wrong, code executed fine but the data not populating on the respective form fields

(但是将数据加载/初始化到表单字段(ReduxForm)上不会填充数据而是执行了代码,有人可以帮助我解决问题或哪里出错了,代码可以很好地执行但数据没有填充到相应的表单字段上)

import "../../views/CSS/Organization.css";
import { Container, Row, Col } from "react-bootstrap";
import {createOrganization} from "../../store/actions/org_actions"
import {connect} from "react-redux"
import moment from 'moment'
import {Field, reduxForm} from 'redux-form'


class Organization extends Component {



        componentDidMount(){

        }


renderInputField = (field)=>(
    <div class='form-group' >
        <div class='oddT-icon-input' >
            <input {...field.input}  placeholder={`${field.placeHolder}`} class='oddT-text' />
            <i class={`${field.icon}`}></i>
        </div>
        <div class="validation-error">{field.meta.touched?field.meta.error:""}</div>
    </div>
  )




  render() {

    return (


<div>
        <Row>
                        <div class='col-sm-6' >
                        <label htmlFor="fePassword">Organization Name</label>
                            <Field 
                                name="orgName"
                                component={this.renderInputField}
                                placeHolder="Organization Name"
                                icon="fa fa-user"
                            />
                        </div>

    </Row>
);

}
}

function mapStateToProps(state,props){
    console.log(state)
    return {
        success: {orgName:"ARSCCOM"},
        initialValues :{orgName:"ARSCCOM"}
    }
}


export default reduxForm({
    validate,
    form: 'Organization',
    enableReinitialize : true

  })(connect(mapStateToProps,{createOrganization})(Organization))

Thank you so much

(非常感谢)

  ask by Nagendra N translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...