abradley2/form-elements/2.0.1

NOTE: the latest version is 4.1.2

FormElements.TextInput

A text input widget for Elm

TEA

view : Model -> Props -> Html Msg

view The view function for displaying the text input element

init : String -> ( Model, Cmd Msg )

init Initialization for the text input model. The id passed in must be unique

update : Msg -> Model -> ( Model, Cmd Msg )

update The update function for the text input element

defaultProps : Props

defaultProps Default props for the text input. Generally the label should be set before passing these defaults to the view

type Msg
= NoOp
| OnInput String
| OnFocus
| OnBlur
| OnInputKeyPress Int

Msg

  • OnInput
type alias Model =
{ id : String
, hasFocus : Bool
}

Model Tracks the internal foxus state of the element

type alias Props =
{ id : String
, label : String
, value : String
, errorText : Maybe String
, helperText : Maybe String
, fieldType : FieldType
}

Props

  • id Unique id for the elements
  • label Label for the text input
  • value The value of the text input
  • errorText Set this to a string when there is a validation error to display to the user. Will override helperText
  • helperText Helpful text displayed under the text input