Skip to content

Commit

Permalink
Generate text data type as textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
acangiano committed Apr 17, 2024
1 parent dfb0c00 commit f37f67f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/mix/tasks/phx.gen.html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ defmodule Mix.Tasks.Phx.Gen.Html do
@moduledoc """
Generates controller with view, templates, schema and context for an HTML resource.
mix phx.gen.html Accounts User users name:string age:integer
mix phx.gen.html Accounts User users name:string age:integer about:text
The first argument, `Accounts`, is the resource's context.
A context is an Elixir module that serves as an API boundary for closely related resources.
The second argument, `User`, is the resource's schema.
A schema is an Elixir module responsible for mapping database fields into an Elixir struct.
The `User` schema above specifies two fields with their respective colon-delimited data types:
`name:string` and `age:integer`. See `mix phx.gen.schema` for more information on attributes.
`name:string`, `age:integer` and `about:text`. See `mix phx.gen.schema` for more information
on attributes.
> Note: A resource may also be split
> over distinct contexts (such as `Accounts.User` and `Payments.User`).
Expand Down Expand Up @@ -198,7 +199,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
4 changes: 2 additions & 2 deletions lib/mix/tasks/phx.gen.live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Mix.Tasks.Phx.Gen.Live do
@moduledoc """
Generates LiveView, templates, and context for a resource.
mix phx.gen.live Accounts User users name:string age:integer
mix phx.gen.live Accounts User users name:string age:integer about:text
The first argument is the context module. The context is an Elixir module
that serves as an API boundary for the given resource. A context often holds
Expand Down Expand Up @@ -290,7 +290,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

0 comments on commit f37f67f

Please sign in to comment.