I'm trying to create html nodes but running into this error:
Web/View/HardwareVendors/Show.hs:7:33
• Couldn't match expected type ‘Text’
with actual type ‘Data.MonoTraversable.Element mono0’
The type variable ‘mono0’ is ambiguous
• In the second argument of ‘forEach’, namely ‘renderInput’
In the first argument of ‘toHtml’, namely
‘((forEach hardwareVendor.required_fields) renderInput)’
In the expression:
toHtml ((forEach hardwareVendor.required_fields) renderInput)
|
7 | html ShowView { .. } = [hsx|
| ^...
related source code:
module Web.View.HardwareVendors.Show where
import Web.View.Prelude
data ShowView = ShowView { hardwareVendor :: HardwareVendor }
instance View ShowView where
html ShowView { .. } = [hsx|
{breadcrumb}
<h1>{hardwareVendor.name}</h1>
<form action="{hardwareVendor.getUrl}" method="get">
-- required_fields is a Text[] postgres column
{forEach hardwareVendor.required_fields renderInput}
<input type="submit" value="Submit">
</form>
|]
where
breadcrumb = renderBreadcrumb
[ breadcrumbLink "HardwareVendors" HardwareVendorsAction
, breadcrumbText "Show HardwareVendor"
]
renderInput :: Text -> Html
renderInput field = [hsx|
<label for="{field}">{field}</label>
<input type="text" id="{field}" name="{field}" required>
<br>
|]
here's some extra filler words because stack overflow validation is silly. here's some extra filler words because stack overflow validation is silly.
Assuming that this is a normal IHP database record, the hardwareVendor.required_fields
should be hardwareVendor.requiredFields
as IHP fields are always camel case