Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Dynamic fields list #60

Merged
merged 17 commits into from
Nov 15, 2016
Merged

Dynamic fields list #60

merged 17 commits into from
Nov 15, 2016

Conversation

etaque
Copy link
Owner

@etaque etaque commented Oct 26, 2016

This PR implements support for dynamic list of fields, as requested in #50

This required a more powerful tree structure so its representation and handling have been extracted to a dedicated module. A few things have changed in the API, that will be a major release.

  • Previously exposed types Field.Field and Error.Error have been renamed to Field.FieldValue and Error.ErrorValue
  • Field and Error are now just trees of values and can be handled by Tree module if needed.
  • in validation, errors must now be wrapped by Error.value
  • for initial fields values, helpers in Field module are now producing tuples
  • list items must be operated with Append and Remove messages
  • input on list item is adressed by index, ie someGroup.0.someField

/cc @amitaibu @DavidHernandez

Copy link
Contributor

@amitaibu amitaibu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, I will review.

@@ -65,7 +61,11 @@ textArea : Input e String
textArea state attrs =
let
formAttrs =
<<<<<<< HEAD
[ defaultValue (state.value ?= "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong merge

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, not sure how that went through tests :D

Copy link
Contributor

@amitaibu amitaibu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor things that I saw. Honestly, I didn't completely get how the new Tree worked, but it seems to be working wonderfully :)

[ class "row link" ]
[ col' 3 [ text "Link" ]
, Input.textInput
(Form.getFieldAsString ("links." ++ (toString i) ++ ".name") form)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link input field's CSS seems to be missing.

elm_simpleform_example

\_ ->
let
( name, value ) =
( "links.0.name", "Twitter" )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering, what happens is the path is wrong?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when wrongly indexed, the input will be ignored. it was adding too much complexity to deal with holes in a list :)

This was referenced Nov 14, 2016
etaque and others added 6 commits November 15, 2016 09:03
 * flipped `andThen`
 * `apply` flipped and renamed to `andMap`
 * renamed:
   * `formN` to `mapN`
   * `get` to `field`
   * `formatError` to `mapError`
 * dissociated input types (`Form.InputType`) and input values
   (`Field.FieldValue`) so now `Field` API follows `Json.Encode`
   * means `Msg(Input)` and  `Form.Input` helpers changed
 * tuples builders for initial fields moved to `Form.Init` module
 * misc 0.18 fixes
@etaque etaque merged commit f9480cb into master Nov 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants