minor cleanups
This commit is contained in:
parent
0fbed68915
commit
ae303a055d
@ -397,20 +397,32 @@ identForm = identifyForm . toPathPiece
|
||||
-----------
|
||||
|
||||
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
|
||||
{ formMethod :: Method
|
||||
, formAction :: SomeRoute site
|
||||
, formAction :: Maybe (SomeRoute site)
|
||||
, formEncoding :: Enctype
|
||||
, formSubmit :: FormSubmitType
|
||||
, 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 formWidget FormSettings{..} = do
|
||||
formId <- maybe newIdent (return . toPathPiece) formAnchor
|
||||
formActionUrl <- toTextUrl formAction
|
||||
formActionUrl <- traverse toTextUrl formAction
|
||||
$(widgetFile "widgets/form/form")
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
$newline never
|
||||
$# 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:
|
||||
$case formSubmit
|
||||
$of FormNoSubmit
|
||||
|
||||
Loading…
Reference in New Issue
Block a user