The task is to create a registration form with pretty error handling.
I'm a newbie in Yesod, so the only way I found to do this is:
regForm :: Form User
getRegRExtra extraFormWidget = do
(formWidget, enctype) <- case extraFormWidget of
Nothing -> generateFormPost regForm
Just val -> return val
defaultLayout $ $(widgetFile "reg/reg")
getRegR = getRegRExtra Nothing
postRegR = do
((result, widget), enctype) <- runFormPostNoToken regForm
case result of
FormSuccess person -> undefined
_ -> getRegRExtra (Just (widget, enctype))
But there is a problem: Page refreshes on every submit while I want it to do this dynamically.
I know it could be fixed with the help of Ajax or Jquery,
but I'll lose all the benefits I get while using Yesod POST functions.
Is there any standard way to deal with that?
The solution is: