Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update :text column to textarea to match intent for html generator #5963

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading