-
Notifications
You must be signed in to change notification settings - Fork 34
How to update multiple form elements at once #68
Comments
Let me see if I understood correctly. You want to dinamically change the form field's values based on the value of other fields, while keeping some values? If that is correct, I would use the FormMsg (Form.Input "fieldToListen" inputType fieldValue) ->
let
newFormValue : List (String, Field)
newFormValue =
[ ( "fieldToListen", Field.value fieldValue )
, Form.Init.setString "changeThiField" "toThisValue"
, Form.Init.setBool "changeThiFieldToo" False
]
in
{ model | form = Form.inital newFormValue formValidation } Note: I haven't used the lastest version of the package, still didn't update my code to Elm 0.18. Code based on the lastest docs (elm-form 1.0.0), didn't test. I don't know if it's the best approach, but it is the one I use (elm-simple-form 4.0.0) and works pretty well. |
The problem with your example above is that you only handle one I have another part of my app that has
But this was possible because my Html elements did not have to return Form.Msg. |
Ok I see the problem. The desired function is (note that Would a |
I'm not sure whether the Input type is necessary, in that it is implicit in the field name, but otherwise this would be ideal. The key need is to be able to create this BatchInput in the view function. I might have function that wants to return a (I have to say I don't really see the the need for the |
That's because the Tree structure has been extracted since list validation, before that logic was duplicated and scattered between field values and errors. |
doc needs tracked in #85 |
I have a form to select products. After you have selected some parameters, the list of remaining possible options is shown. When you click one all the remaining parameter selects are completed for you.
I used to use Form.Reset to create a message with multiple form values, which I then intercepted in the update function to get the list and add those to the model, rather than letting the list be used to reinitialise the form.
Now the problem for me is that Form.Reset takes
List ( String, Field )
whereas the update function needsFieldvalue
s, and there is no functionField -> Fieldvalue
So far I've come up with
The text was updated successfully, but these errors were encountered: