相关疑难解决方法(0)

以编程方式更改Redux-Form字段值

当我使用redux-formv7时,我发现没有办法设置字段值.现在在我form,我有两个select组件.当第一个select组件值发生变化时,第二个值将清晰.

在类渲染中:

<div className={classNames(style.line, style.largeLine)}>
  <div className={style.lable}>site:</div>
  <div className={style.content}>
    <Field
      name="site"
      options={sites}
      clearable={false}
      component={this.renderSelectField}
      validate={[required]}
    />
  </div>
</div>

<div className={classNames(style.line, style.largeLine)}>
  <div className={style.lable}>net:</div>
  <div className={style.content}>
    <Field
      name="net"
      options={nets}
      clearable={false}
      component={this.renderSelectField}
      validate={[required]}
      warning={warnings.net}
    />
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

现在我添加select更改挂钩,如何更改其他select

renderSelectField = props => {
  const {
    input,
    type,
    meta: { touched, error },
    ...others
  } = props
  const { onChange } = input
  const _onChange = value => {
    onChange(value)
    this.handleSelectChange({ …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux redux-form

27
推荐指数
1
解决办法
3万
查看次数

redux-form如何加载数据进行编辑

我正在使用redux-form它,似乎使我无法加载用于编辑表单的初始数据,但是提交时未对数据进行验证。我已经设法将数据传递并加载到字段中,但是似乎没有加载到props等表单中。请查看以下代码,如果需要更多内容,请告诉我。

Form_Bayan.js

import React, {Component, PropTypes} from "react";  
import {browserHistory} from "react-router";        
import {reduxForm, Field} from "redux-form";

import {MyCustomInput, MySimpleInput, MyCustomSelect} from "./__form_field_components";

import {connect} from "react-redux";
import {bindActionCreators} from "redux";
import {
    ADMIN_FETCH_AUTOSUGGESTS_Lbl,
    adminFetchAutoSuggestCats_act,
    ADMIN_GETCATID_BYNAME_Lbl,
    adminGetCatIdByName_act,
    ADMIN_ADDNEWBAYAAN_Lbl,
    adminAddNewBayaan_act,
    adminFetchArticlesByCat_act,
    adminUpdateBayaan_act
} from "../../actions/adminActionCreators";
import _ from "lodash";


class NewBayanForm extends Component {

    constructor(props) {
        super(props);       

        this.state = {
            submitButtonMeta: {
                btnTitle: "Save",
                btnClass: "btn btn-default",
                btnIcon: null,
                disabled: false
            },
            globalMessage: {                        // set when an action …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux-form react-redux

6
推荐指数
2
解决办法
4262
查看次数

标签 统计

javascript ×2

reactjs ×2

redux-form ×2

react-redux ×1

redux ×1