primait / pyxis-components / Prima.Pyxis.Form.RadioButton

Configuration


type RadioButton model msg

Represent the opaque RadioButton configuration.


type alias RadioButtonChoice =
{ value : String
, title : String
, subtitle : Maybe String 
}

Represent the RadioButtonChoice configuration.

Configuration Methods

radioButton : (model -> Maybe String) -> (String -> msg) -> List RadioButtonChoice -> RadioButton model msg

Create a radioButton.

radioButtonChoice : String -> String -> RadioButtonChoice

Create the 'RadioButtonChoice' configuration.

radioButtonChoiceWithSubtitle : String -> String -> String -> RadioButtonChoice

Create the 'radioButtonChoiceWithSubtitle' configuration.

Rendering

render : model -> RadioButton model msg -> List (Html msg)

Renders the Input.

import Html
import Prima.Pyxis.Form.RadioButton as RadioButton
import Prima.Pyxis.Form.Validation as Validation

...

type Msg =
    OnChange String


type alias Model =
    { tipoPolizza: Maybe String }

...

view : Html Msg
view =
    Html.div
        []
        (Input.email .tipoPolizza OnInput
            |> Input.withClass "my-custom-class"
            |> Input.withValidation (Maybe.andThen validate << .tipoPolizza)
        )

validate : String -> Validation.Type
validate str =
    if String.isEmpty str then
        Just <| Validation.ErrorWithMessage "Tipo di polizza is empty".
    else
        Nothing

Options

withAttribute : Html.Attribute msg -> RadioButton model msg -> RadioButton model msg

Adds a generic Html.Attribute to the RadioButton.

withClass : String -> RadioButton model msg -> RadioButton model msg

Adds a class to the RadioButton.

withId : String -> RadioButton model msg -> RadioButton model msg

Adds an id Html.Attribute to the RadioButton.

withDisabled : Basics.Bool -> RadioButton model msg -> RadioButton model msg

Adds disabled Html.Attribute to the RadioButton.

Event Options

withOnBlur : msg -> RadioButton model msg -> RadioButton model msg

Attaches the onBlur event to the RadioButton.

withOnFocus : msg -> RadioButton model msg -> RadioButton model msg

Attaches the onFocus event to the RadioButton.

Validation

withValidation : (model -> Maybe Prima.Pyxis.Form.Validation.Type) -> RadioButton model msg -> RadioButton model msg

Adds a Validation rule to the RadioButton.