Skip to content

fabiommendes/elm-dynamic-forms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elm Dynamic Forms

Implement forms that are generated server-side from JSON data. This is useful to integrate your Elm frontend with models and forms generated by the backend. Build Status

Install Elm Dynamic Forms

elm package install fabiommendes/elm-dynamic-forms

This package was create to interop with Django. If that is also your use case, please check the sister project https://github.com/fabiommendes/django-dynamic-forms/.

Features

  • Leverages elm-form library to perform validation and representation of form values.
  • Conversion of complete form data from/to JSON.
  • Read and serialize form content to JSON to easily interop with the backend.

Basic usage

See the example validation test suite and test helper function docs for how to test-drive validations.

-- TODO

JSON format

Dynamic forms defines a simple JSON format for serialization of form declarations.

{
    "action": "/foo/bar",
    "fields": {
        "name": {
            "type": "string",
            "label": "Name",
            "placeholder": "Full name",
            "help": "Your name and family name in the order you'd like to be called.",
            "validators": [["max-length", 200]],
        },
        "age": {
            "type": "integer",
            "label": "Age",
            "help": "Your age",
            "validators": [["min-value", 0], ["max-value", 120]],
        }
    },
    "data": {
        "name": "R2D2"
    },
    "layout": {
        "type": "linear",
        "fields": ["name", "age"]
    }
}