actions.submit 和 actions.submit 字段有什么区别?
What's the difference between actions.submit and actions.submitFields?
actions.submit() 和 actions.submitReact-redux-forms 中的字段有什么区别?不幸的是,文档在这个问题上不是很清楚。
我已经测试了这两个功能 - 我的表单名为 'feature' 并且只有 firstName 和 lastName 输入框。
这是我所做的:
1) actions.submit('feature.firstName', somePromise)
除了发送如下所示的 rrf/addIntent 操作外,似乎没有做任何事情:
类型(引脚):"rrf/addIntent"
型号(引脚):"feature.lastName"
类型(引脚):"submit"
2) actions.submit('feature')
这实际上提交了与我的按钮行为完全相同的表单
<button type="submit">
submit me!
</button>
3) actions.submit字段('feature.firstName', somePromise)
同 1)
4) actions.submit字段('feature')
同 2)
据我所知,actions.submit 和 actions.submit字段完全相同。
并且提供了 actions.submit,因此您可以分派该操作,这样您就可以提交表单而无需单击提交按钮。
我遗漏了什么吗?
谢谢!
从 ts 文档中可以看出,一个字段一个字段一个字段地处理 validation/errors,而常规提交在整个表单上 validation/error 添加:
/**
* Waits for a submission promise to be completed, then, if successful:
* * Sets .submitted property of form for model to true
* * Sets .validity property of form for model to the response (or true if the response is undefined).
*
* If the promise fails, the action will:
* * set .submitFailed property of form for model to true
* * set .errors property of form for model to the response
*
* @param model The top-level model form key of the data to submit.
* @param promise The promise that the submit action will wait to be resolved or rejected
*/
submit: (model: string | ModelGetterFn, promise?: Promise<any> | undefined, options?: any) => ActionThunk;
/**
* Waits for a submission promise to be completed, then, if successful:
* * Sets .submitted property of form for model to true
* * Each key in the response, which represents a sub-model (e.g., "name" for users.name) will have its .validity set to its value.
*
* If the promise fails, the action will:
*
* * set .submitFailed property of form for model to true
* * Each key in the response, which represents a sub-model (e.g., "name" for users.name) will have its .errors set to its value. (See example)
*
* @param model (String | Function): the model to be submitted
* @param promise (Promise): the promise that the submit action will wait to be resolved or rejected
*/
submitFields: (model: string | ModelGetterFn, promise: Promise<any>) => ActionThunk;
actions.submit() 和 actions.submitReact-redux-forms 中的字段有什么区别?不幸的是,文档在这个问题上不是很清楚。
我已经测试了这两个功能 - 我的表单名为 'feature' 并且只有 firstName 和 lastName 输入框。
这是我所做的:
1) actions.submit('feature.firstName', somePromise)
除了发送如下所示的 rrf/addIntent 操作外,似乎没有做任何事情:
类型(引脚):"rrf/addIntent" 型号(引脚):"feature.lastName" 类型(引脚):"submit"
2) actions.submit('feature')
这实际上提交了与我的按钮行为完全相同的表单
<button type="submit">
submit me!
</button>
3) actions.submit字段('feature.firstName', somePromise)
同 1)
4) actions.submit字段('feature')
同 2)
据我所知,actions.submit 和 actions.submit字段完全相同。
并且提供了 actions.submit,因此您可以分派该操作,这样您就可以提交表单而无需单击提交按钮。
我遗漏了什么吗?
谢谢!
从 ts 文档中可以看出,一个字段一个字段一个字段地处理 validation/errors,而常规提交在整个表单上 validation/error 添加:
/**
* Waits for a submission promise to be completed, then, if successful:
* * Sets .submitted property of form for model to true
* * Sets .validity property of form for model to the response (or true if the response is undefined).
*
* If the promise fails, the action will:
* * set .submitFailed property of form for model to true
* * set .errors property of form for model to the response
*
* @param model The top-level model form key of the data to submit.
* @param promise The promise that the submit action will wait to be resolved or rejected
*/
submit: (model: string | ModelGetterFn, promise?: Promise<any> | undefined, options?: any) => ActionThunk;
/**
* Waits for a submission promise to be completed, then, if successful:
* * Sets .submitted property of form for model to true
* * Each key in the response, which represents a sub-model (e.g., "name" for users.name) will have its .validity set to its value.
*
* If the promise fails, the action will:
*
* * set .submitFailed property of form for model to true
* * Each key in the response, which represents a sub-model (e.g., "name" for users.name) will have its .errors set to its value. (See example)
*
* @param model (String | Function): the model to be submitted
* @param promise (Promise): the promise that the submit action will wait to be resolved or rejected
*/
submitFields: (model: string | ModelGetterFn, promise: Promise<any>) => ActionThunk;