composable-form | Build type-safe composable forms in Elm | Functional Programming library
kandi X-RAY | composable-form Summary
kandi X-RAY | composable-form Summary
Build type-safe composable forms in Elm
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of composable-form
composable-form Key Features
composable-form Examples and Code Snippets
Community Discussions
Trending Discussions on composable-form
QUESTION
I'm trying to implement a dynamic form in Elm 0.19 using hecrj/composable-form.
I receive a json with the fields, their descriptions, etc, so I don't know beforehand how many fields it will have.
So the traditional way of defining a form:
...ANSWER
Answered 2020-Dec-04 at 22:58The form library doesn't explicitly support what you're trying to do, but we can make it work!
tldr;Here's my example of how you can take JSON and create a form: https://ellie-app.com/bJqNh29qnsva1
How to get thereForm.list
is definitely the promising path. You're also exactly right that Form.list
requires all of the fields to be of the same type. So let's start there! We can make one data structure that can hold them by making a custom type. In my example, I called it DynamicFormFieldValue
. We'll make a variant for each kind of field. I created ones for text, integer, and select list. Each one will need to hold the value of the field and all of the extras (like title and default value) to make it show up nicely. This will be what we decode the JSON into, what the form value is, and what the form output will be. The resulting types looks like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install composable-form
Elm packages are available at elm-lang.org. If you are going to make HTTP requests, you may need elm/http and elm/json. You can get them set up in your project with the following commands: elm install elm/http and elm install elm/json. It adds these dependencies into your elm.json file, making these packages available in your project. Please refer guide.elm-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page