Search code examples
syntaxelm

How to fix error when creating a button under text input?


I want to create a button under these 2 text inputs. I just overtook the code from the docs. But I get this error :

The div function expects 2 arguments, but it got 5 instead.

How can I solve this?

-- VIEW


view : Model -> Html Msg
view model =
  div []
    [ input [ placeholder  "Team 1", style "width" "300px", style "height" "30px", style "font-size" "25px", value model.content ] []
    , input [ placeholder  "Strength", style "width" "300px", style "height" "30px", style "font-size" "25px", value model.content ] []
    ]

  div []
    [ button [ style "color" "white", style "height" "60px", style "font-size" "30px", style "margin-right" "70px"]
    ]

Solution

  • Your code, with the children omitted, can be reformatted to

    div [] [ ... ] div [] [ ... ]
    

    Do you see why the compiler thinks you're giving div five arguments?

    Since view should return a single element you'll have to wrap the div's in some other element, like another div:

    div []
      [ div [] [ ... ]
      , div [] [ ... ]
      ]