Comments (18)
Okay, I'll implement and document it later. Thanks for idea and discussion.
from uniforms.
@radekmie you mentioned validate=onChangeAfterSubmit
is this a part of the current api? I could not see a reference to that, so I'm curious. Or is this something you are thinking of implementing?
from uniforms.
@serkandurusoy yes, it is. I've just discovered it's not described in README. More informations are available in packages/uniforms/src/components/forms/ValidatedForm.js
. I'll update README later.
from uniforms.
Wow this is great news!
What about getting the state of the form and/or individual inputs in terms of their values have been changed or not? I think their error status is already available but I think we don't have a very straightforward way of knowing if values have been edited, right?
from uniforms.
Again, it's an idea for functionality. I'll think about it and later make a draft of API.
from uniforms.
Hmm I think we can provide an onChange(key, value) function and listed to that to set some state, but yeah, it is not directly in the api.
thanks for giving it consideration!
from uniforms.
Okay, I think it could be like this - every field will receive a changed
prop (PropTypes.bool.isRequired
) - that should be enough (for fields). Also, every form could have changed
field in it's state (same type), that could be a part of context.uniforms.state
. Does it makes sense for you?
from uniforms.
Yep, a changed
prop on fields and changed
on context.state
for form is quite sufficient.
from uniforms.
For the following model:
{
a: {
b: 1,
c: [
2
]
}
}
We've got there the following cases:
- When
a.b
has changed, then botha
anda.b
are marked as changed. - When
a.c.0
has changed, then alla
,a.c
anda.c.0
are marked as changed. - When
a.c.1
appears, then botha
anda.c
are marked, but what witha.c.1
- has it changed? - When
a.c.0
is removed, then added again, is it changed?
from uniforms.
1 and 2 makes sense.
3, I think yes a.c.1 has changed because previously, a.c[1] was undefined
and now not! so I would expect it to be reported as changed
4, yes it has changed. because if you remove a.c[0] it has changed at that point. readding it does not guarantee equality because it would be a new empty value initially.
Whatabout reording arrays? It would be best if you would be able to keep track of individual array items as they get reordered
from uniforms.
Reordering is also change, becouse model's field x is now x' and field y is now y' (I think). There's another problem - what about reordering equal values?
from uniforms.
I would say that also constitutes a change.
Perhaps the thinking would be, if user has interacted with the form, whatever the event target has been, and bubbling up the parent up to the form itself, has been changed.
from uniforms.
At that point, I think it should be up the developer to keep track of those changes and decide accordingly.
Even react itself has a shouldComponentUpdate directive becuase deep equality checking is expensive so we should not be caring to compare before and after states in deep structures.
from uniforms.
Let's summarize: if field has changed (adding or removing array item is a change too), it's marked as changed
. That status bubbles up to the form component.
from uniforms.
Yep, I think that's it.
from uniforms.
Sure thing! Thank you for the package and being so awesome with feature requests!
from uniforms.
I've wrote few tests, but it would be better to test it within exact use case (or write more tests).
from uniforms.
Sure thing! I am going to be using this in a project in the following days
and I'll definitely report back my findings if I see anything out of place.
Thanks!
On Sun, May 29, 2016 at 9:10 PM, Radosław Miernik [email protected]
wrote:
I've wrote few tests, but it would be better to test it within exact
use case (or write more tests).—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#12 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AEbz3I5PQna0KzzBXWYVs-brcSO4z3Apks5qGdaWgaJpZM4IouYG
.
from uniforms.
Related Issues (20)
- AutoForm does not include wrapped custom field in onModelChangeEvent HOT 2
- Warning: Failed prop type: Invalid prop `required` of type `array` supplied to `ForwardRef(FormControl)`, expected `boolean`. HOT 1
- Getting Invariant error Field not present in schema file.0 HOT 3
- uniforms-bootstrap5 is setting the minLength and maxLength in the wrapper, instead of in textarea
- DisplayIf required validation and on hide still data passes to model HOT 2
- Schema validation does not work if AutoForm as onValidate HOT 3
- Vertical form layout is broken for antd v5 HOT 1
- How can I send defaultValue to AutoForm HOT 1
- Support v5 of AntD HOT 3
- ZodBridge should ignore literal property type HOT 4
- Option to use JSON Schema `description` property as a helper text HOT 3
- Error with Hydration integrating with Next 13 HOT 2
- Support for lazy recursive JSON schemas HOT 2
- $ref in subschemas
- Input values are not updated as I type in the fields HOT 3
- Using AutoField with schema containing patternProperties HOT 1
- [ZOD] Implement logic to handle Zod.discriminatedUnion HOT 1
- How to remove the time in data-time field? I only want date. HOT 2
- Overriding componentDetectorContext HOT 2
- How to scroll to error field? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uniforms.