If we defined 2 simple objects in our model file, for example: -
Person name Text Age Int Book title Text author Text
We can define the applicative form for a book as: -
addBookForm = renderDivs $ Book <$> areq textField "title" Nothing <*> areq textField "author" Nothing
However, if we want to change the author only from the text field, to the person’s identifier, as: -
Book title Text author PersonId
Then the above form will not be compiled with this error: -
Couldn't match expected type `KeyBackend Database.Persist.GenericSql.Raw.SqlBackend Person' with actual type `Text' Expected type: Field sub0 master0 (KeyBackend Database.Persist.GenericSql.Raw.SqlBackend Person) Actual type: Field sub0 master0 Text In the first argument of `areq', namely `textField' In the second argument of `(<*>)', namely `areq textField "author" Nothing'
How do we now define the author’s field? Do I need to use a monadic form?
Thanks!
source share