Repository: phoenixframework/phoenix (elixir)

Issue:
phoenix.gen.html form incomplete
### Environment

* Elixir version (elixir -v): Elixir 1.4.5
  Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
* Phoenix version (mix deps): phoenix 1.2.4 (Hex package) (mix)
                                                  locked at 1.2.4 (phoenix) 4172479b
OR
                                                  phoenix 1.3.0-rc.2 (Hex package) (mix)
                                                  locked at 1.3.0-rc.2 (phoenix) 53104ada
* NodeJS version (node -v): v8.1.2
* NPM version (npm -v): 5.0.3
* Operating system: macOS Sierra (10.12.5)

### Expected behavior

Running this command 
```mix phoenix.gen.html Thing things name:string colors:array:string```
should result in a form with a text field for "name" and some kind of selector (drop-down, collection of checkboxes) for the "colors".

### Actual behavior

Only "name" field is generated in the "form.html.eex" file -- see [example generated app](https://github.com/hassan/elixir-forms-example)

Pull request:
Generate multiple_select input in form for array fields.
This PR resolves #2381 

However, I'm not sure if just generate integer values for `array:integer`, and string values for other typs is sufficient, or I should generate different type for those possible arguments like `array:time` things. Please advise, thanks!

Patch:
diff --git a/guides/docs/controllers.md b/guides/docs/controllers.md
index c9d052a8a..2c9c801ae 100644
--- a/guides/docs/controllers.md
+++ b/guides/docs/controllers.md
@@ -549,6 +549,7 @@ Let's say we have a `show` action which uses `with` to fetch a blog post and the
 defmodule HelloWeb.MyController do
   use Phoenix.Controller
   alias Hello.{Authorizer, Blog}
+  alias HelloWeb.ErrorView
 
   def show(conn, %{"id" => id}, current_user) do
     with {:ok, post} <- Blog.fetch_post(id),
diff --git a/lib/mix/tasks/phx.gen.html.ex b/lib/mix/tasks/phx.gen.html.ex
index 2c72bd941..692137703 100644
--- a/lib/mix/tasks/phx.gen.html.ex
+++ b/lib/mix/tasks/phx.gen.html.ex
@@ -182,8 +182,6 @@ defmodule Mix.Tasks.Phx.Gen.Html do
 
   defp inputs(%Schema{} = schema) do
     Enum.map(schema.attrs, fn
-      {_, {:array, _}} ->
-        {nil, nil, nil}
       {_, {:references, _}} ->
         {nil, nil, nil}
       {key, :integer} ->
@@ -204,6 +202,10 @@ defmodule Mix.Tasks.Phx.Gen.Html do
         {label(key), ~s(<%= datetime_select f, #{inspect(key)}, class: "form-control" %>), error(key)}
       {key, :naive_datetime} ->
         {label(key), ~s(<%= datetime_select f, #{inspect(key)}, class: "form-control" %>), error(key)}
+      {key, {:array, :integer}} ->
+        {label(key), ~s(<%= multiple_select f, #{inspect(key)}, ["1": 1, "2": 2], class: "form-control" %>), error(key)}
+      {key, {:array, _}} ->
+        {label(key), ~s(<%= multiple_select f, #{inspect(key)}, ["Option 1": "option1", "Option 2": "option2"], class: "form-control" %>), error(key)}
       {key, _}  ->
         {label(key), ~s(<%= text_input f, #{inspect(key)}, class: "form-control" %>), error(key)}
     end)


Test patch:
diff --git a/lib/phoenix/test/conn_test.ex b/lib/phoenix/test/conn_test.ex
index a48b16a5f..926627009 100644
--- a/lib/phoenix/test/conn_test.ex
+++ b/lib/phoenix/test/conn_test.ex
@@ -112,7 +112,7 @@ defmodule Phoenix.ConnTest do
   """
   @spec build_conn() :: Conn.t
   def build_conn() do
-    build_conn(:get, "/", [])
+    build_conn(:get, "/", nil)
   end
 
   @doc """
@@ -134,8 +134,8 @@ defmodule Phoenix.ConnTest do
   This is useful when a specific connection is required
   for testing a plug or a particular function.
   """
-  @spec build_conn(atom | binary, binary, binary | list | map) :: Conn.t
-  def build_conn(method, path, params_or_body \\ []) do
+  @spec build_conn(atom | binary, binary, binary | list | map | nil) :: Conn.t
+  def build_conn(method, path, params_or_body \\ nil) do
     Plug.Adapters.Test.Conn.conn(%Conn{}, method, path, params_or_body)
     |> Conn.put_private(:plug_skip_csrf_protection, true)
     |> Conn.put_private(:phoenix_recycled, true)
@@ -144,7 +144,7 @@ defmodule Phoenix.ConnTest do
   @doc """
   Deprecated version of conn/3. Use build_conn/3 instead
   """
-  @spec conn(atom | binary, binary, binary | list | map) :: Conn.t
+  @spec conn(atom | binary, binary, binary | list | map | nil) :: Conn.t
   def conn(method, path, params_or_body \\ nil) do
     IO.write :stderr, """
     warning: using conn/3 to build a connection is deprecated. Use build_conn/3 instead.
diff --git a/test/mix/tasks/phx.gen.html_test.exs b/test/mix/tasks/phx.gen.html_test.exs
index e79a1c68a..5c4d3292d 100644
--- a/test/mix/tasks/phx.gen.html_test.exs
+++ b/test/mix/tasks/phx.gen.html_test.exs
@@ -108,6 +108,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
         assert file =~ ~s(<%= text_input f, :title, class: "form-control" %>)
         assert file =~ ~s(<%= number_input f, :votes, class: "form-control" %>)
         assert file =~ ~s(<%= number_input f, :cost, step: "any", class: "form-control" %>)
+        assert file =~ ~s(<%= multiple_select f, :tags, ["Option 1": "option1", "Option 2": "option2"], class: "form-control" %>)
         assert file =~ ~s(<%= checkbox f, :popular, class: "checkbox" %>)
         assert file =~ ~s(<%= datetime_select f, :drafted_at, class: "form-control" %>)
         assert file =~ ~s(<%= datetime_select f, :published_at, class: "form-control" %>)
@@ -119,6 +120,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
         assert file =~ ~s(<%= label f, :title, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :votes, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :cost, class: "control-label" %>)
+        assert file =~ ~s(<%= label f, :tags, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :popular, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :drafted_at, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :published_at, class: "control-label" %>)
@@ -127,7 +129,6 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
         assert file =~ ~s(<%= label f, :alarm, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :secret, class: "control-label" %>)
 
-        refute file =~ ":tags"
         refute file =~ ~s(<%= label f, :user_id)
         refute file =~ ~s(<%= number_input f, :user_id)
       end