minor cleanups
This commit is contained in:
parent
0fbed68915
commit
ae303a055d
@ -397,20 +397,32 @@ identForm = identifyForm . toPathPiece
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
data FormSubmitType = FormNoSubmit | FormSubmit | FormDualSubmit
|
data FormSubmitType = FormNoSubmit | FormSubmit | FormDualSubmit
|
||||||
deriving (Eq, Ord, Enum, Read, Show, Typeable, Generic)
|
deriving (Eq, Ord, Enum, Bounded, Read, Show, Typeable, Generic)
|
||||||
|
|
||||||
|
instance Universe FormSubmitType
|
||||||
|
instance Finite FormSubmitType
|
||||||
|
|
||||||
data FormSettings site = FormSettings
|
data FormSettings site = FormSettings
|
||||||
{ formMethod :: Method
|
{ formMethod :: Method
|
||||||
, formAction :: SomeRoute site
|
, formAction :: Maybe (SomeRoute site)
|
||||||
, formEncoding :: Enctype
|
, formEncoding :: Enctype
|
||||||
, formSubmit :: FormSubmitType
|
, formSubmit :: FormSubmitType
|
||||||
, formAnchor :: Maybe FormIdentifier
|
, formAnchor :: Maybe FormIdentifier
|
||||||
}
|
} deriving (Generic, Typeable)
|
||||||
|
|
||||||
|
instance Default (FormSettings site) where
|
||||||
|
def = FormSettings
|
||||||
|
{ formMethod = methodPost
|
||||||
|
, formAction = Nothing
|
||||||
|
, formEncoding = UrlEncoded
|
||||||
|
, formSubmit = FormSubmit
|
||||||
|
, formAnchor = Nothing
|
||||||
|
}
|
||||||
|
|
||||||
wrapForm :: (Button site ButtonSubmit) => WidgetT site IO () -> FormSettings site -> WidgetT site IO ()
|
wrapForm :: (Button site ButtonSubmit) => WidgetT site IO () -> FormSettings site -> WidgetT site IO ()
|
||||||
wrapForm formWidget FormSettings{..} = do
|
wrapForm formWidget FormSettings{..} = do
|
||||||
formId <- maybe newIdent (return . toPathPiece) formAnchor
|
formId <- maybe newIdent (return . toPathPiece) formAnchor
|
||||||
formActionUrl <- toTextUrl formAction
|
formActionUrl <- traverse toTextUrl formAction
|
||||||
$(widgetFile "widgets/form/form")
|
$(widgetFile "widgets/form/form")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
$newline never
|
$newline never
|
||||||
$# Wrapper for all kinds of forms
|
$# Wrapper for all kinds of forms
|
||||||
<form ##{formId} method=#{decodeUtf8 formMethod} action=#{formActionUrl} enctype=#{formEncoding}>
|
<form ##{formId} method=#{decodeUtf8 formMethod} action=#{fromMaybe "" formActionUrl} enctype=#{formEncoding}>
|
||||||
$# Distinguish different falvours of submit button layouts here:
|
$# Distinguish different falvours of submit button layouts here:
|
||||||
$case formSubmit
|
$case formSubmit
|
||||||
$of FormNoSubmit
|
$of FormNoSubmit
|
||||||
|
|||||||
Reference in New Issue
Block a user