Closed JordanMartinez closed 2 years ago
If you need a field which is itself an array of fields, then the field (as far as Formless is concerned) will be coordinating among several fields (as far as the browser / UI events are concerned). Your best bet is to render the browser fields so each one tracks its index in the array and updates its value there appropriately.
Environment
purescript-halogen
v5.0.0-rc.7purescript-halogen-formless
v1.0.0-rc.1Current behavior
Formless does not provide a type that can be used in the row of fields to indicate that the row is a collection of fields. To workaround this limitation, one can use a nested form based on the example in this repo.
However, the above example is not as "real world" as it could be in the following ways:
Maybe (Array entity)
rather than anArray entity
.Here's my use case. I have a form with a dynamic array of entities that need to be submitted. On one run, there might only be one entity. In another, it might be as many as 6. Each entity has two fields. The submit button should only be clickable when all of the entities' 2 fields are valid. When the submit button is clicked, it should raise a
Array entity
, not aMaybe (Array entity)
.Expected behavior
The developer can use a custom Formless-provided type that indicates that a given row is a collection of fields.
I'm not sure how the above could be supported. While
collection
could beIdentity
in normal situations andArray
/List
/Maybe
in other situations, the definition also allows a weird sort of case (e.g.Map someKey
) that might not make sense.Example Code
Note: I haven't actually run this code to verify whether it works as intended. I do know that it compiles.