Comments (7)
Thanks for creating the issue and your feedback. I am in the process of revising the technical implementation of the acktive
state and the recognition of field arrays. I am aware of the problem through several issues and technically it can all be solved. However, I am currently writing my bachelor thesis and cannot say with certainty when I will get to the implementation.
from modular-forms.
However, I have already fixed some of the problems. Please test the whole thing once in the latest version. The length should work according to my tests.
from modular-forms.
Thank you, I will give the newest version a try :)
from modular-forms.
Yes, the newest version fixes that issue!
One question though: When I remove an item from an array via remove
the array is not returned when calling getValues(form, { shouldDirty: true })
. Is there even such a thing as a dirty
state on an ArrayField
?
Or is that something that is supposed to be implemented in userland?
from modular-forms.
Yes, field arrays also have their own dirty
state. However, this is probably not yet fully implemented for the shouldDirty
option. The dirty
state changes whenever the items of a field array are changed by remove
, insert
and so on. Would the expected behavior on your part be that only then the array is returned or also when a field in the array is dirty
?
from modular-forms.
Would the expected behavior on your part be that only then the array is returned or also when a field in the array is dirty?
Well, I don't know; it seems very case specific. I'll try to explain my usecase:
I have a gallery
FieldArray, each item having "file" and "caption" fields. The API requires me to send the whole gallery
array whenever there is a change inside (either fields values or added/removed enrties)
But when there is no change, I do not want to send the gallery
array at all (null).
Currently I use <Form shouldDirty ... />
and in the onSubmit
handler I check if gallery
is defined. If it is defined, I use getValues(form, "gallery")
to fetch all fields inside. This approach however does not work when removing items from the array, since gallery
will be undefined (= no changes).
I was thinking of using a custom diff function. I could remove shouldDirty
from <Form>
, receiving all in the function argument and compare values
with the initial values, as deeply as I need to. Basically writing my own "isDirty" check.
But for that I need a way to access the initial values from the form
. Can I just use form.internal…
?
Or do you have any other ideas how to solve the problem?
from modular-forms.
Yes, you can use form.internal
. I don't recommend it for most users, but if you know what you're doing, it's fine. I think that in the long run, I may be able to solve this problem. Basically, the library needs to check if a field array is dirty
or at least one contained field and if so, return the field array. However, since I am currently writing my bachelor thesis, I cannot give a timeframe for when I will get to the technical implementation.
from modular-forms.
Related Issues (20)
- Qwik: Latest qwik release breaks types HOT 14
- Enhance FieldStore to Return Multiple Errors per Field HOT 2
- Phone Number Input HOT 1
- Allow setting initial form values of a mounted component HOT 2
- Preact: What is the best method to pull values of fields in the form for using in computed() HOT 4
- [Question] Is it possible to have optional fields? HOT 7
- Import error in formAction for qwik HOT 1
- Checkbox works improperly when use modular forms with kobalte HOT 7
- [Question] Is it possible to have custom input without ref? HOT 5
- When useFormStore is in a seperate file, it fails HOT 1
- Select component with number types HOT 3
- Using modular form Fields inside solidjs Dynamic component HOT 1
- Qwik: Vite is trying to externalize packages used in formAction$ HOT 3
- `requestSubmit` is not a function on Safari < 16 HOT 3
- Does this library support React Native? HOT 1
- Internal issue: Cannot read properties of null (reading 'internal') HOT 4
- SolidJS: Form reset action doesn't preventDefault like submit does. HOT 1
- [Qwik] Form state is reset after action returns an error HOT 1
- [React]: Preact Signals Dependency Update HOT 11
- [SolidJS]: How to handle errors from server? HOT 3
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 modular-forms.