Skip to content

Commit dde8ba5

Browse files
committed
fix(renderer): Allow to pass custom subscription
1 parent 1aef5ac commit dde8ba5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/react-form-renderer/src/form-renderer/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const FormRenderer = ({
4141
validate,
4242
onStateUpdate,
4343
renderFormButtons,
44+
subscription,
4445
}) => {
4546
const inputSchema = schemaMapper(schemaType)(schema, uiSchema);
4647
let schemaError;
@@ -66,7 +67,7 @@ const FormRenderer = ({
6667
...initialValues,
6768
}}
6869
validate={ validate }
69-
subscription={{ pristine: true, submitting: true, valid: true }}
70+
subscription={{ pristine: true, submitting: true, valid: true, ...subscription }}
7071
render={ ({ handleSubmit, pristine, valid, form: { reset, mutators, getState, submit, ...form }, ...state }) => (
7172
<RendererContext.Provider value={ configureContext({
7273
layoutMapper,
@@ -135,6 +136,7 @@ FormRenderer.propTypes = {
135136
validate: PropTypes.func,
136137
onStateUpdate: PropTypes.func,
137138
renderFormButtons: PropTypes.oneOfType([ PropTypes.node, PropTypes.element, PropTypes.func ]),
139+
subscription: PropTypes.shape({ [PropTypes.string]: PropTypes.bool }),
138140
};
139141

140142
FormRenderer.defaultProps = {

packages/react-renderer-demo/src/docs-components/renderer-api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ Form Renderer provides a lot of customization via props.
3131
|initialValues|object|An object of fields names as keys and values as their values.||
3232
|schemaType|one of `['mozilla', 'miq', 'default']`|Data driven forms includes two basic parsers: mozilla and manageiq service dialogs.|'default'|
3333
|showFormControls|bool|You can disable showing form buttons. Use it with wizard component which has its own buttons.|true|
34+
|subscription|object|You can pass your own [subscription](https://final-form.org/docs/react-final-form/types/FormProps#subscription), which will be added to default settings.|`{ pristine: true, submitting: true, valid: true }`|
3435
|uiSchema|object|Use when you need to use mozilla schema.|{ }|
3536
|<NavLink to="/renderer/validators">validate</NavLink>|func|A function which receives all form values and returns an object with errors.||

0 commit comments

Comments
 (0)