Skip to content

Commit

Permalink
Allow a submit button to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
amitaibu committed Dec 23, 2023
1 parent ae76491 commit 935c32e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions IHP/View/CSSFramework.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ instance Default CSSFramework where

styledValidationResultClass = ""

styledSubmitButton cssFramework SubmitButton { label, buttonClass } =
styledSubmitButton cssFramework SubmitButton { label, buttonClass, disabled } =
let className :: Text = cssFramework.styledSubmitButtonClass
in [hsx|<button class={classes [(className, True), (buttonClass, not (null buttonClass))]} type="submit">{label}</button>|]
in [hsx|<button class={classes [(className, True), (buttonClass, not (null buttonClass))]} disabled={disabled} type="submit">{label}</button>|]

styledInputClass _ _ = ""
styledInputInvalidClass _ _ = "invalid"
Expand Down
1 change: 1 addition & 0 deletions IHP/View/Form.hs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ submitButton =
{ label = cs $ (if isNew then "Create " else "Save ") <> buttonText
, buttonClass = mempty
, cssFramework = ?formContext.cssFramework
, disabled = False
}
{-# INLINE submitButton #-}

Expand Down
1 change: 1 addition & 0 deletions IHP/View/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ data SubmitButton = SubmitButton
{ label :: Blaze.Html
, buttonClass :: Text
, cssFramework :: CSSFramework
, disabled :: Bool
}

data FormContext model = FormContext
Expand Down

0 comments on commit 935c32e

Please sign in to comment.