在字段组件中,有一种获取表单名称的方法吗?我对不同的表单使用相同的输入组件,实际上我使用了一个硬代码表单名称,但是我想找到一种方法来获取包含输入的表单名称。
class FormField extends Component {
process = () => {
nameForm= 'myForm'; // hardcode, i'd like to get the form parent
const values = this.props.myState.form[nameForm].values;
(...)
我正在用动态表单(redux-form)构建一个应用程序。我想当用户点击提交按钮打印值。请注意,我的提交按钮放置在我的应用程序头(在表单之外)。为了实现这一点,我从Redux表单跟踪这个。当我按下“保存”按钮时,我在我的控制台中得到了一个错误:(0 , _reduxForm.submit) is not a function(…)。
我的代码:
提交组件
import React from 'react'
import {connect} from 'react-redux'
import {submit} from 'redux-form'
我想问一问,我在代码中错过了什么。当我提交表单时,submitForm函数似乎无法工作/触发。我无法从表单字段中获得值。这是我的密码:
import React from 'react';
import { reduxForm,reset, Field } from 'redux-form';
class FormProfile extends React.Component {
submitForm(formProps){
console.log(formProps);
}
render(){
co
是否可以让redux-form验证根据单击的提交按钮进行不同的验证?
例如,如果我“提交”一个表单,运行一个完整的验证,但如果我“保存”一个表单,然后只运行部分检查?
到目前为止,我还没有在validate函数中看到过类似的东西。使用同步验证
function validate(values, props) {
//handle validation
//Check what type of validation to handle
}
<Button onClick={handleSubmit(this.props.save.bind(this))}>Save<
在Redux-form v5中,我可以从修饰的表单中的任何位置访问“内联”错误(异步验证),如下所示:
const fields = [
'email'
]
// inside the decorated form
const { email } = this.props.fields
console.log(email.error) // 'the validation error of the 'email' field
如何使用Redux-form 6.0.0+实现相同的功能?