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 1 commit into
base: main
Choose a base branch
from

Conversation

acangiano
Copy link

Currently, mix phx.gen.html (and mix phx.gen.live) generate a single-line input field even if the user specifies text as the data type. For example:

mix phx.gen.html Blog Post posts title:string body:text

will generate the following form which is not what most users would expect.

Posts

In essence, there is no distinction between string and text types as far as the generated HTML goes (though, the distinction exists in the generated migration file).

This small patch allows for fields declared as text to be generated as <textarea>.

improved-posts

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find that using a textarea for text-type fields is a positive change, but the current docs changes do not help convey that distinction. It is probably not worth documenting anyway, as people are free and encouraged to change the generated code.

IMHO I'd keep the example mix call shorter as it was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants