Represent the opaque Flag
configuration.
flag : (model -> Maybe Basics.Bool) -> (Basics.Bool -> msg) -> String -> Flag model msg
Create a Flag
.
render : model -> Flag model msg -> List (Html msg)
Input
.import Html
import Prima.Pyxis.Form.Flag as Flag
import Prima.Pyxis.Form.Validation as Validation
...
type Msg =
OnCheck Bool
type alias Model =
{ privacy: Maybe Bool }
...
view : Html Msg
view =
Html.div
[]
(Flag.flag .privacy OnInput
|> Input.withValidation (Maybe.andThen validate << .privacy)
)
validate : Maybe Bool -> Validation.Type
validate privacy=
if isJust privacy then
Just <| Validation.ErrorWithMessage "Privacy cannot be blank".
else
Nothing
withAttribute : Html.Attribute msg -> Flag model msg -> Flag model msg
Adds a generic Html.Attribute to the Input
.
withDisabled : Basics.Bool -> Flag model msg -> Flag model msg
Sets a disabled
to the Flag config
.
withLabel : Prima.Pyxis.Form.Label.Label msg -> Flag model msg -> Flag model msg
Adds a Label
Html.Attribute to the Flag
.
withName : String -> Flag model msg -> Flag model msg
Adds a name
Html.Attribute to the Flag
.
withOnBlur : msg -> Flag model msg -> Flag model msg
Attaches the onBlur
event to the Flag
.
withOnFocus : msg -> Flag model msg -> Flag model msg
Attaches the onFocus
event to the Flag
.
withValidation : (model -> Maybe Prima.Pyxis.Form.Validation.Type) -> Flag model msg -> Flag model msg
Adds a Validation
rule to the Flag
.