From 3033953cc93ea0f721084cbc1d4d77842963eafd Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 18 Jan 2017 11:49:09 +1300 Subject: [PATCH] API Scaffolded redux form fields have the parent form name assigned as a property Requirement for https://github.com/silverstripe/silverstripe-asset-admin/pull/370 --- admin/client/dist/js/bundle.js | 4 ++-- admin/client/src/components/FormBuilder/FormBuilder.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/admin/client/dist/js/bundle.js b/admin/client/dist/js/bundle.js index a2154c441..5ba9c6213 100644 --- a/admin/client/dist/js/bundle.js +++ b/admin/client/dist/js/bundle.js @@ -384,7 +384,7 @@ t=l({},t,t.input),delete t.input var i=this.props.createFn return"function"==typeof i?i(n,t):f["default"].createElement(n,l({key:t.id},t))}},{key:"mapFieldsToComponents",value:function v(e){var t=this,n=this.props.baseFieldComponent return e.map(function(e){var i=e -return e.children&&(i=l({},e,{children:t.mapFieldsToComponents(e.children)})),i=l({onAutofill:t.props.onAutofill},i),"Structural"===e.type||e.readOnly===!0?t.buildComponent(i):f["default"].createElement(n,l({ +return e.children&&(i=l({},e,{children:t.mapFieldsToComponents(e.children)})),i=l({onAutofill:t.props.onAutofill,form:t.props.form},i),"Structural"===e.type||e.readOnly===!0?t.buildComponent(i):f["default"].createElement(n,l({ key:i.id},i,{component:t.buildComponent}))})}},{key:"mapActionsToComponents",value:function y(e){var t=this return e.map(function(e){var n=l({},e) return e.children?n.children=t.mapActionsToComponents(e.children):(n.handleClick=t.handleAction,t.props.submitting&&t.state.submittingAction===e.name&&(n.loading=!0)),t.buildComponent(n)})}},{key:"normalizeFields", @@ -425,7 +425,7 @@ case"alpha":return u["default"].isAlpha(e) case"regex":return u["default"].matches(e,n.pattern) case"max":return e.length<=n.length case"email":return u["default"].isEmail(e) -default:console.warn("Unknown validation rule used: '"+t+"'")}}},{key:"validateFieldSchema",value:function l(e){return this.validateField(e.name,e.validation,null!==e.leftTitle?e.leftTitle:e.title,e.customValidationMessage) +default:return console.warn("Unknown validation rule used: '"+t+"'"),!1}}},{key:"validateFieldSchema",value:function l(e){return this.validateField(e.name,e.validation,null!==e.leftTitle?e.leftTitle:e.title,e.customValidationMessage) }},{key:"getMessage",value:function d(e,t){var n="" if("string"==typeof t.message)n=t.message diff --git a/admin/client/src/components/FormBuilder/FormBuilder.js b/admin/client/src/components/FormBuilder/FormBuilder.js index 603e655ba..0deb35687 100644 --- a/admin/client/src/components/FormBuilder/FormBuilder.js +++ b/admin/client/src/components/FormBuilder/FormBuilder.js @@ -185,7 +185,10 @@ class FormBuilder extends SilverStripeComponent { ); } props = Object.assign( - { onAutofill: this.props.onAutofill }, + { + onAutofill: this.props.onAutofill, + form: this.props.form, + }, props );