@@ -21,37 +21,58 @@ class FieldProvider extends Component{
2121
2222 render ( ) {
2323 const { clearOnUnmount, component, render, dataType, children, ...props } = this . props ;
24+ const fieldClearedValue = props . hasOwnProperty ( 'clearedValue' ) ? props . clearedValue : props . formOptions . clearedValue ;
25+ const { clearedValue, ...fieldProps } = props ;
2426 if ( component ) {
2527 const FieldComponent = component ;
26- return < Field { ...props } render = { ( { input : { onChange, ...input } , ...fieldsProps } ) => (
28+ return < Field { ...fieldProps } render = { ( { input : { onChange, ...input } , ...fieldsProps } ) => (
2729 < FieldComponent
2830 { ...fieldsProps }
2931 input = { {
3032 ...input ,
31- onChange : ( ...args ) => enhancedOnChange ( dataType , onChange , ...args ) ,
33+ onChange : ( ...args ) => {
34+ enhancedOnChange ( {
35+ ...fieldsProps . meta ,
36+ dataType,
37+ onChange,
38+ clearedValue : fieldClearedValue ,
39+ } , ...args ) ;
40+ } ,
3241 } }
3342 />
3443 ) } /> ;
3544 }
3645
3746 if ( render ) {
38- return < Field { ...props } render = { ( { input : { onChange, ...input } , ...fieldsProps } ) => render ( {
47+ return < Field { ...fieldProps } render = { ( { input : { onChange, ...input } , ...fieldsProps } ) => render ( {
3948 ...fieldsProps ,
4049 input : {
4150 ...input ,
42- onChange : ( ...args ) => enhancedOnChange ( dataType , onChange , ...args ) ,
51+ onChange : ( ...args ) =>
52+ enhancedOnChange ( {
53+ ...fieldsProps . meta ,
54+ dataType,
55+ onChange,
56+ clearedValue : fieldClearedValue ,
57+ } , ...args ) ,
4358 } ,
4459 } ) } /> ;
4560 }
4661
4762 const ChildComponent = children ;
4863 return (
49- < Field { ...props } >
64+ < Field { ...fieldProps } >
5065 { ( { input : { onChange, ...input } , ...fieldsProps } ) =>
5166 Children . only (
5267 < ChildComponent
5368 { ...fieldsProps }
54- input = { { ...input , onChange : ( ...args ) => enhancedOnChange ( dataType , onChange , ...args ) } }
69+ input = { { ...input , onChange : ( ...args ) =>
70+ enhancedOnChange ( {
71+ ...fieldsProps . meta ,
72+ dataType,
73+ onChange,
74+ clearedValue : fieldClearedValue ,
75+ } , ...args ) } }
5576 />
5677 ) }
5778 </ Field >
@@ -64,6 +85,7 @@ FieldProvider.propTypes = {
6485 clearOnUnmount : PropTypes . bool ,
6586 change : PropTypes . func ,
6687 getFieldState : PropTypes . func ,
88+ clearedValue : PropTypes . any ,
6789 } ) ,
6890 component : PropTypes . oneOfType ( PropTypes . node , PropTypes . element , PropTypes . func ) ,
6991 render : PropTypes . func ,
0 commit comments