为所有表单字段实现字段规范化

时间:2016-02-24 07:27:26

标签: redux-form

您好我想实现大写的表单规范化,例如Normalizing Form Data

const reducer = combineReducers({
  // other reducers
  form: form.normalize({
    normalizing: {                                    // <--- name of the form
      upper: value => value && value.toUpperCase(),   // normalizer for 'upper' field
      phone: normalizePhone,                          // normalizer for 'phone' field
      min: normalizeMin,                              // normalizer for 'min' field
      max: normalizeMax                               // normalizer for 'max' field
    }
  })
});

我有100个字段,我不想写每个字段但是传递某种类型的数组,就像那样。

const reducer = combineReducers({
  // other reducers
  form: form.normalize({
    normalizing: {                                    // <--- name of the form
      fieldsArray: value => value && value.toUpperCase(),   // normalizer for 'upper' field
    }
  })
});

如何实现这一目标?

1 个答案:

答案 0 :(得分:0)

Erik R在他的项目中发表了答案 https://github.com/erikras/redux-form/issues/685