haskellyesodyesod-forms

haskell - How to check one default radio in a radioFieldList in yesod


I am writing a web app where people can check one radio in a radioFieldList for every image displayed. And the result will be stored in a database. For every new image, the radios of radioFieldList are all unchecked. I also make a 'prev' submit button. When the 'prev' button is clicked, the previous image will be displayed. Now I want to check one of the radios according to the user's previous choice of this image.

However, I cannot find any example or method in the Yesod tutorial.
((result,widget),enctype) <- runFormPost selectForm

This only builds a unchecked radioFieldList.

How can I set default checked radio for a radioFieldList.


Solution

  • I presume you're using something like areq (radioField ...) "Some Name" Nothing right now. That Nothing value means "no default." To provide a default, replace it with (Just someDefault).