This module is useful if you want to add a Select Form element to your app.
Add a Select.Model to your model.
myInitialModel : MyModel
myInitialModel =
{ mySelect = Select.init [Mr, Ms, Dr]
}Add a Select.Msg to your Msg.
type MyMsg
= UpdateMySelect Select.MsgUse in your update function.
myUpdate : Msg -> Model -> (Model, Cmd Msg)
myUpdate msg model =
case msg of
UpdateMySelect selectMsg ->
let
(newSelect, cmd) =
Select.update selectMsg mode.mySelect
in
{ model | mySelect = newSelect } ! [ cmd ]Transform an Select.Model into an Select.View, which allows us to pipe View Setters on it.
myView : Model -> Html Msg
myView model =
div
[]
[ Select.view model.mySelect -- pipe view setters here, for example |> setIsLocked 'your logic here'
]Transforms an Select.View into Html Select.Msg
myView : Model -> Html Msg
myView model =
div
[]
[ Select.view model.mySelect
|> Select.render
|> Html.map UpdateMySelect
]ReInitialise your Select.Model.
Reset your Select.Model.
Set the initial option of your Select.Model.
Change the option of your Select.Model.
This function allows you to disable specific options.
Set whether your select is in error mode (red border).
Set whether your select is locked (disabled).
Set whether your select is clearable (x icon).
Set the default label, for example (-- NOTHING SELECTED --).
Set how your options are printed to the screen.
Give your select an id. Can be useful for DOM selectors (focus, WebComponents etc.)
Whether your select was changed. Useful if you want to disable save buttons unless there were changes etc.
Whether this select is currently open.
Get the initial option of your select.
Get the current option of your select. This is what you'd use to display the data somewhere outside of your select, or to send the data to the backend for example etc.
Useful if you need the id of the select in your update function, so set focus etc.
Add a Select.Model to your model.