Skip to content

Commit

Permalink
Update phx.gen.html.ex (#5963)
Browse files Browse the repository at this point in the history
Update :text column to textarea to match intent for html generator
  • Loading branch information
lifeiscontent authored Nov 17, 2024
1 parent dad4527 commit 222d9ab
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/mix/tasks/phx.gen.html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ defmodule Mix.Tasks.Phx.Gen.Html do
~s(<.input field={f[#{inspect(key)}]} type="checkbox" label="#{label(key)}" />)

{key, :text} ->
~s(<.input field={f[#{inspect(key)}]} type="text" label="#{label(key)}" />)
~s(<.input field={f[#{inspect(key)}]} type="textarea" label="#{label(key)}" />)

{key, :date} ->
~s(<.input field={f[#{inspect(key)}]} type="date" label="#{label(key)}" />)
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/phx.gen.live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ defmodule Mix.Tasks.Phx.Gen.Live do
~s(<.input field={@form[#{inspect(key)}]} type="checkbox" label="#{label(key)}" />)

{key, :text} ->
~s(<.input field={@form[#{inspect(key)}]} type="text" label="#{label(key)}" />)
~s(<.input field={@form[#{inspect(key)}]} type="textarea" label="#{label(key)}" />)

{key, :date} ->
~s(<.input field={@form[#{inspect(key)}]} type="date" label="#{label(key)}" />)
Expand Down
4 changes: 3 additions & 1 deletion test/mix/tasks/phx.gen.html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
datetime = %{DateTime.utc_now() | second: 0, microsecond: {0, 6}}

in_tmp_project(config.test, fn ->
Gen.Html.run(~w(Blog Post posts title slug:unique votes:integer cost:decimal
Gen.Html.run(~w(Blog Post posts title content:text slug:unique votes:integer cost:decimal
tags:array:text popular:boolean drafted_at:datetime
status:enum:unpublished:published:deleted
published_at:utc_datetime
Expand Down Expand Up @@ -110,6 +110,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
assert_file(path, fn file ->
assert file =~ "create table(:posts)"
assert file =~ "add :title, :string"
assert file =~ "add :content, :text"
assert file =~ "add :status, :string"
assert file =~ "create unique_index(:posts, [:slug])"
end)
Expand Down Expand Up @@ -151,6 +152,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
assert_file("lib/phoenix_web/controllers/post_html/post_form.html.heex", fn file ->
assert file =~ ~S(<.simple_form :let={f} for={@changeset} action={@action}>)
assert file =~ ~s(<.input field={f[:title]} type="text")
assert file =~ ~s(<.input field={f[:content]} type="textarea")
assert file =~ ~s(<.input field={f[:votes]} type="number")
assert file =~ ~s(<.input field={f[:cost]} type="number" label="Cost" step="any")

Expand Down
4 changes: 3 additions & 1 deletion test/mix/tasks/phx.gen.live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defmodule Mix.Tasks.Phx.Gen.LiveTest do

test "generates live resource and handles existing contexts", config do
in_tmp_live_project config.test, fn ->
Gen.Live.run(~w(Blog Post posts title slug:unique votes:integer cost:decimal
Gen.Live.run(~w(Blog Post posts title content:text slug:unique votes:integer cost:decimal
tags:array:text popular:boolean drafted_at:datetime
status:enum:unpublished:published:deleted
published_at:utc_datetime
Expand Down Expand Up @@ -88,6 +88,7 @@ defmodule Mix.Tasks.Phx.Gen.LiveTest do
assert_file path, fn file ->
assert file =~ "create table(:posts)"
assert file =~ "add :title, :string"
assert file =~ "add :content, :text"
assert file =~ "create unique_index(:posts, [:slug])"
end

Expand All @@ -102,6 +103,7 @@ defmodule Mix.Tasks.Phx.Gen.LiveTest do
assert_file "lib/phoenix_web/live/post_live/form.ex", fn file ->
assert file =~ ~s(<.simple_form)
assert file =~ ~s(<.input field={@form[:title]} type="text")
assert file =~ ~s(<.input field={@form[:content]} type="textarea")
assert file =~ ~s(<.input field={@form[:votes]} type="number")
assert file =~ ~s(<.input field={@form[:cost]} type="number" label="Cost" step="any")
assert file =~ """
Expand Down

0 comments on commit 222d9ab

Please sign in to comment.