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

Generate text data type as textarea #5784

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
acangiano marked this conversation as resolved.
Show resolved Hide resolved

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