version | 10.0.0 |
license | MIT |
native-modules | False |
elm-version | 0.15.1 <= v < 0.17.0 |
Tag | 10.0.0 |
Committed At | 2016-04-03 21:13:41 UTC |
tripokey/elm-fuzzy | 5.0.0 <= v < 6.0.0 | 5.2.1 |
sgraf812/elm-intdict | 1.4.2 <= v < 2.0.0 | 1.4.3 |
rluiten/elm-date-extra | 3.0.0 <= v < 4.0.0 | 3.0.0 |
evancz/elm-html | 3.0.0 <= v < 5.0.0 | 4.0.2 |
evancz/elm-effects | 2.0.0 <= v < 3.0.0 | 2.0.1 |
elm-lang/core | 2.1.0 <= v < 4.0.0 | 3.0.0 |
circuithub/elm-list-split | 1.0.1 <= v < 2.0.0 | 1.0.1 |
This package tries to provide a very simple and powerful interface to HTML(5) forms powered by bootstrap. It uses evancz/elm-html as HTML rendering backend.
See agrafix/elm-bootforms on the central elm package repo.
import Date
import Html.Form.Input as I
type alias Model =
{ date: I.FormValue String Date.Date
, name: I.FormValue String String
}
type Action
= Nop
| SetDate (I.FormValueAction String Date.Date)
| SetName (I.FormValueAction String String)
init : (Model, Effects Action)
init =
(
{ date = { userInput = "", value = Err "no date", focused = False }
, name = I.stringFormVal ""
}
, Effects.none
)
noFx : Model -> (Model, Effects Action)
noFx m = (m, Effects.none)
update : Action -> Model -> (Model, Effects Action)
update a m =
case a of
Nop -> noFx m
SetDate f -> ({ m | date = I.apply f m.date }, I.mappedEffect SetDate f)
SetName f -> ({ m | name = I.apply f m.name }, I.mappedEffect SetName f)
view : Signal.Address Action -> Model -> H.Html
view addr =
H.lazy <| \m ->
H.div []
[ H.h2 [] [ text "My super form" ]
, I.dateInput
{ id = "some-date"
, label = "Date"
, helpBlock = Just "Example: 04.02.2015"
, value = m.date
, onValue = Signal.message addr << SetDate
}
, I.textInput
{ id = "some-name"
, label = "The name"
, helpBlock = Just "Example: 14:35"
, value = m.name
, onValue = Signal.message addr << SetDeparture
}
}
Install using elm-package.