0

Apparently, Halogen lacks "dialog" value of method attribute. As of writing the words, the method attribute in Halogen has only get and post values.

The good news though is Halogen says that when this happens it's not a problem as these may be added by a user.

So that's exactly what I'm trying to do here, but the code fails with error and I don't exactly see how to work around it:

module Main where

import Prelude

import Effect (Effect)
import Halogen (PropName(..))
import Halogen as H
import Halogen.Aff as HA
import Halogen.Aff (awaitBody, runHalogenAff)
import Halogen.HTML (prop)
import Halogen.HTML as HH
import Halogen.HTML.Properties (IProp)
import Halogen.HTML.Properties as HP
import Halogen.VDom.Driver (runUI)

main :: Effect Unit
main = HA.runHalogenAff do
  body <- HA.awaitBody
  runUI component unit body

component :: ∀ query input output m. H.Component query input output m
component =
  H.mkComponent { initialState: const 0, render, eval: H.mkEval H.defaultEval}
  where
    render _ = HH.div_
               [ HH.dialog [HP.style "padding: 0"]
                   [HH.form [HP.style "padding: 1rem", method "dialog"] []]
               ]
      where
        method :: forall r i. String -> IProp (method :: String | r) i
        method = prop (PropName "method")

error:

Error found:
in module Main
at src/Main.purs:27:54 - 27:69 (line 27, column 54 - line 27, column 69)

  Could not match type

    String

  with type

    FormMethod


while matching label method

I also tried creating a HH.attr (AttrName "method") "dialog" but it doesn't seem to work.

1 Answer 1

2

Actually, HH.attr (AttrName "method") "dialog" does seem to be the way to declare such attribute. It probably didn't work for me because of some other error.

So basically, the answer is that declaring the value alone won't work here, but you can re-declare whole attribute with the value instead.

I also sent a PR to implement the missing value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.