如何在提交失败的表单后显示验证消息?API请求返回HTTP 400'应用程序/问题+ json'响应,并将违规包含为具有字段路径的列表.
https://tools.ietf.org/html/rfc7807#section-3
{
"type": "https://example.net/validation-error",
"title": "Your request parameters didn't validate.",
"invalid-params": [
{
"name": "age",
"reason": "must be a positive integer"
},
{
"name": "color",
"reason": "must be 'green', 'red' or 'blue'"
}
]
}
Run Code Online (Sandbox Code Playgroud) 我找不到隐藏输入的方法取决于一些记录值.我试图import { formValueSelector } from 'redux-form'获得当前状态,但我失败了.
export default props =>
<Edit {...props}>
<SimpleForm>
<DisabledInput source="id"/>
<NumberInput options={opts} source="age" />
{
props.record.age > 18 &&
<TextInput options={opts} source="question"/>
}
</SimpleForm>
</Edit>
Run Code Online (Sandbox Code Playgroud)