enonic / app-explorer

Other
1 stars 3 forks source link

Require name on Collection #22

Closed ComLock closed 5 years ago

ComLock commented 5 years ago

Preferably client side validation

ComLock commented 5 years ago

https://github.com/bvego/nope-validator

ComLock commented 5 years ago

Validation exposed a problem with the current implementation, I have come across before.

Since a collector's form inputs are loaded from another bundle, the formik context gets lost. I worked around this by passing on the "formikBag" to each component.

There's a lot of complexity with regards to validation, that formik handles easily when using formik components. One can make custom components by wrapping them with formik.Field.

The problem though is that formik.Field requires formik.Context to work, so my workaround doesn't work at all!

I think the proper solution is to

Something like this: https://codesandbox.io/s/formik-multiple-form-in-one-submission-kbf1w?fontsize=14

@sigdestad has been talking about an collector app's own configuration popping up in a modal window, whos form could be implemented in whatever the collector app's developer chooses. This would be a step in that direction.

ComLock commented 5 years ago

Yes, that idea worked out. A collector app should provide a full formik form with it's own values and validation. (and use React.useEffect to call onChange everytime values changes)

This means that if a collector receives values that Enonic XP has BORKED from [value] to value, it can forceArray that itself, without requiring changes to the main explorer application.