Closed abalmos closed 8 years ago
I really want to bring this in, though it would be nice to review it together maybe? Let me know when you have some spare time @abalmos. Would be cool to get it to a publishable version :)
@christianalfoni Let me see if I can find a few hours this week to finish this up. I have some notes that I need to review from when I used it in a project.
@abalmos After resetting the Form options.map will be null when trying to render a select. options is undefined after reset. See Select/index.js
@abalmos We need to check the reset.js I think.
Thanks for review @edgesoft ! I will wait for @abalmos final pull request before official release :)
These changes (including fixes for the comments left by @edgesoft, thanks @edgesoft!) are now in the branch misc-features
. I'm too chicken to update the branch this PR is based on because I don't want to break my production app :smiley:
I didn't merge into master because I know I will have trouble being around to support the code for a few weeks. The branch also lacks updated documentation (although there is a complete demo form). I will let @christianalfoni decide if he just wants to pull the trigger and merge or wait for some PRs on that branch to add docs.
@abalmos can you aslo make a rebase on top of latest master?
@Guria the misc-features
branch is this PR + a few commits rebased onto master
@abalmos ahh then we should open new pr instead of this one I suppose?
I am closing this PR to avoid further confusion. Please track the misc-features
branch for these changes. Unfortunately I can't update this PR because the current master uses cerebral API too new for my production application.
@Guria I suppose we could. No semantic versioning here yet so I can just merge the branch into master when ready. The point of moving it into a branch on this repo was to enable some PRs on the feature branch from others in the meantime.
@abalmos @Guria @christianalfoni I'm using this in production now and It works great. No bugs so far. Could we pull misc-features into master branch or what is stopping us?
@edgesoft probably the only thing that is stopping it is me not yet writing documentation on the new stuff. There is a breaking change or two. For example,touched
changed meaning slightly.
I'll get doing this on my to-do list
Per a Discord conversation instead of pulling my forms solution out of its project I refactored the project to use
cerebral-module-forms
because I liked its overall design more. However, the module is missing some features I need so here is an attempt at adding them.I am aware that some or all of this may not make it or may need a second revision. Hopefully this PR will be a spring board for discussions. Sorry all of theses features are jammed into one PR, I have to go live with my project by the end of the week so I hacked together what I needed all at once :smile: That said, I tried my best to make one commit per feature.
@christianalfoni Let me know if you are not ready for PRs like this. I don't want to step on your new module too much!
What's in the PR
Bug Fixes:
New Features
<select multiple>
defaultValue
state key and provided a reset action and reset signal.isTouched
to only set for on blur and forced validations. We talked a little about this on Discord. I think it improves the UX.touched
input key to thefieldChanged
signal and then made the react parts do the right thing. There is probably a better solution.New Features I Wanted To Get To But Ran Out Of Time, For Now...
Custom errors
i18n libraries could be used at this level.
function (value, previousValue, cursor, form, parameter)
. This could get somewhat complicated because the cursor position needs to be considered and updated appropriately too.Updating the view based on form values. For example, show a picture of the credit card type as soon as it can be determined from the numbers entered. Change the label of the "CVV" field to "CID" for American Express, etc.
cerebral-module-forms
. I just wanted the demo to include it so we have an example of how one could do it.and
where the object at
meta
is stored in the field's state under ameta
key. I want to avoid allowing the validators/normalizers to arbitrarily change a fields state because I think that is asking for trouble/abuse.Open Questions/Thoughts:
cerebral-module-forms
as a page sub-module and let the form state be owned by thecerebral-module-forms
instance. Would/could that make the signals easier to use? We would avoiding having to register all the custom validators for an entire application in one place. However, then some rules might be included more than once across various forms.