digitallyinduced/ihp-multi-records-form-example

Adding values to tags

Closed this issue ยท 2 comments

Hey ๐Ÿ‘‹ I am trying to get back into Haskell via IHP and want to add values to tags. I added a form field and managed to extract them, but how do I put them together when building a record?

    action CreateTaskAction = do
        let task = newRecord @Task
        let names :: [Text] = paramList "tags_name"
        let values :: [Text] = paramList "tags_value"
        let tags = names |> map (buildTag newRecord)

You can try sometihng like let namesAndValues :: [(Text, Text)] = zip names values and then let tags = namesAndValues |> map (buildTag newRecord)

And then adjust the buildTag like this buildTag (name, value) tag = ...