1

Is there some builtin method for HTML text field completion with a simple <datalist> in IHP? E.g. as in https://stackoverflow.com/a/19779010/69663

unhammer
  • 4,306
  • 2
  • 39
  • 52

1 Answers1

3

Grepping the IHP code it seems not, but it was easy to just do it "manually":

instance View NewView where
    html NewView { .. }  = [hsx|
        {renderForm thing}
        <datalist id="languages">
          {forEach languages renderOption}
        </datalist>
|]

renderForm :: Thing -> Html
renderForm thing = formFor thing [hsx|
    {(textField #language) { additionalAttributes = [("list", "languages")]}}
|]

renderOption :: Text -> Html
renderOption value = [hsx| <option value={value}/> |]

unhammer
  • 4,306
  • 2
  • 39
  • 52