Note that there are some explanatory texts on larger screens.

plurals
  1. POGrouped checkboxes in Haskell/Yesod
    primarykey
    data
    text
    <p>I am currently developing with Haskell on the Yesod web platform and I need to create a form in one of my webpages. This form must contain several checkboxes, but they need to be grouped into categories. For instance, the user would need to select 3 disciplines in a list of 10 checkboxes, 5 items and of those a maximum of 2 can be weapons. </p> <p>I have read parts of the book on the Yesod website, and from my understanding I would need to create a custom field to create grouped checkboxes. Unfortunately, I am not very good with Haskell (have just started using it 1-2 weeks ago) and I have some difficulties understanding how I could achieve this. For reference, this is the page that I have read of the book on Yesod's website that talks about custom fields: <a href="http://www.yesodweb.com/book/forms">http://www.yesodweb.com/book/forms</a></p> <p>Knowing that, my question would be: how do I create grouped checkboxes in Haskell/Yesod?</p> <p>EDIT: In the link I have provided, I understand the last two values of the constructor of Field (fieldView and fieldEnctype), it is the first one (fieldParse) that I do not know how to modify for my purpose. Here is the example in the link that I was referencing:</p> <pre><code>passwordConfirmField :: Field Handler Text passwordConfirmField = Field { fieldParse = \rawVals _fileVals -&gt; case rawVals of [a, b] | a == b -&gt; return $ Right $ Just a | otherwise -&gt; return $ Left "Passwords don't match" [] -&gt; return $ Right Nothing _ -&gt; return $ Left "You must enter two values" , fieldView = \idAttr nameAttr otherAttrs eResult isReq -&gt; [whamlet| &lt;input id=#{idAttr} name=#{nameAttr} *{otherAttrs} type=password&gt; &lt;div&gt;Confirm: &lt;input id=#{idAttr}-confirm name=#{nameAttr} *{otherAttrs} type=password&gt; |] , fieldEnctype = UrlEncoded } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload