@@ -34,13 +34,16 @@ export const FormControls = ({
3434 FormButtons,
3535 Button,
3636 ButtonGroup,
37- formSpyProps
37+ formSpyProps,
38+ buttonsProps,
39+ buttonGroupProps
3840} ) => {
3941 if ( FormButtons ) {
4042 return < FormButtons /> ;
4143 }
4244
4345 const { submitting, pristine, validating } = formSpyProps ;
46+ const { submit, reset, cancel } = buttonsProps ;
4447
4548 const buttons = {
4649 submit : (
@@ -51,14 +54,17 @@ export const FormControls = ({
5154 buttonType = "submit"
5255 disabled = { submitting || validating || disableSubmit }
5356 label = { submitLabel }
57+ { ...submit }
5458 />
5559 ) ,
56- reset : canReset ? < Button key = "form-reset" type = "button" buttonType = "reset" disabled = { pristine } onClick = { onReset } label = { resetLabel } /> : null ,
57- cancel : onCancel ? < Button key = "form-cancel" type = "button" buttonType = "cancel" onClick = { onCancel } label = { cancelLabel } /> : null
60+ reset : canReset ? (
61+ < Button key = "form-reset" type = "button" buttonType = "reset" disabled = { pristine } onClick = { onReset } label = { resetLabel } { ...reset } />
62+ ) : null ,
63+ cancel : onCancel ? < Button key = "form-cancel" type = "button" buttonType = "cancel" onClick = { onCancel } label = { cancelLabel } { ...cancel } /> : null
5864 } ;
5965
6066 return (
61- < ButtonGroup { ...( buttonClassName && { className : buttonClassName } ) } >
67+ < ButtonGroup { ...buttonGroupProps } { ... ( buttonClassName && { className : buttonClassName } ) } >
6268 { completeButtons ( buttonOrder ) . map ( ( button ) => buttons [ button ] ) }
6369 </ ButtonGroup >
6470 ) ;
@@ -85,7 +91,9 @@ FormControls.propTypes = {
8591 reset : PropTypes . func
8692 } ) ,
8793 values : PropTypes . object
88- } )
94+ } ) ,
95+ buttonGroupProps : PropTypes . object ,
96+ buttonsProps : PropTypes . object
8997} ;
9098
9199FormControls . defaultProps = {
@@ -94,7 +102,8 @@ FormControls.defaultProps = {
94102 resetLabel : 'Reset' ,
95103 canReset : false ,
96104 canSubmit : false ,
97- buttonOrder : [ 'submit' , 'reset' , 'cancel' ]
105+ buttonOrder : [ 'submit' , 'reset' , 'cancel' ] ,
106+ buttonsProps : { }
98107} ;
99108
100109const FormTemplate = ( {
@@ -107,6 +116,11 @@ const FormTemplate = ({
107116 showFormControls,
108117 disableSubmit,
109118 Header,
119+ headerProps,
120+ titleProps,
121+ descriptionProps,
122+ buttonGroupProps,
123+ buttonsProps,
110124 ...rest
111125} ) => {
112126 const {
@@ -118,9 +132,9 @@ const FormTemplate = ({
118132 return (
119133 < FormWrapper onSubmit = { handleSubmit } { ...formWrapperProps } >
120134 { ( title || label || description ) && (
121- < Header >
122- { ( title || label ) && < Title > { title || label } </ Title > }
123- { description && < Description > { description } </ Description > }
135+ < Header { ... headerProps } >
136+ { ( title || label ) && < Title { ... titleProps } > { title || label } </ Title > }
137+ { description && < Description { ... descriptionProps } > { description } </ Description > }
124138 </ Header >
125139 ) }
126140 { formFields }
@@ -130,6 +144,8 @@ const FormTemplate = ({
130144 < FormControls
131145 Button = { Button }
132146 FormSpy = { FormSpy }
147+ buttonGroupProps = { buttonGroupProps }
148+ buttonsProps = { buttonsProps }
133149 ButtonGroup = { ButtonGroup }
134150 onReset = { onReset }
135151 onCancel = { onCancel }
@@ -153,7 +169,12 @@ FormTemplate.propTypes = {
153169 formWrapperProps : PropTypes . object ,
154170 showFormControls : PropTypes . bool ,
155171 disableSubmit : PropTypes . arrayOf ( PropTypes . string ) ,
156- Header : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func , PropTypes . element , PropTypes . oneOf ( [ React . Fragment ] ) ] )
172+ Header : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func , PropTypes . element , PropTypes . oneOf ( [ React . Fragment ] ) ] ) ,
173+ headerProps : PropTypes . object ,
174+ titleProps : PropTypes . object ,
175+ descriptionProps : PropTypes . object ,
176+ buttonGroupProps : PropTypes . object ,
177+ buttonsProps : PropTypes . object
157178} ;
158179
159180FormTemplate . defaultProps = {
0 commit comments