Capturing Persistent Relations in a Form

前端 未结 1 608
灰色年华
灰色年华 2021-01-25 13:45

I have defined a one-to-many relationship in Persistent but could not figure out how to create a form that can take one of the foreign keys as input. Simplifying my use case to

相关标签:
1条回答
  • 2021-01-25 14:41

    I was able to figure out how to use selectField properly. This is what I ended up doing:

    where
        people = do
            entities <- runDB $ selectList [] [Asc PersonName]
            optionsPairs $ map (\p -> (personName $ entityVal p, entityKey p)) entities
    

    The form field became:

    <$> areq   (selectField people) "Person Name" Nothing
    

    I still have not figured out free form entry just yet but this is a good start.

    0 讨论(0)
提交回复
热议问题