You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sibi Prabakaran edited this page Jun 22, 2016
·
3 revisions
[WARNING] Yesod Cookbook has moved to a new place. Please contribute there.
Change the order of form fields
If you have an applicative form, but you don't want the form fields to be displayed in the same order as the field of your data type, then a lambda is the easiest solution:
dataD1=D1{d1f1::T.Text
, d1f2::(MaybeT.Text)
, d1f3::Integer}deriving (Eq, Show)
form::RenderMessagemasterFormMessage=>MaybeD1->Html->Formsubmaster (FormResultD1, GWidgetsubmaster())
form d = renderDivs $ (\a b c ->D1 b a c)
<$> aopt textField "field2" (d1f2 <$> d)
<*> areq textField "field1" (d1f1 <$> d)
<*> areq intField "field3" (d1f3 <$> d)
If you need more control over the form layout than this, it's best to switch to monadic forms.