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

Add ‘rows' attribute to the textarea, with a default value of 2 rows. #665

Merged
merged 6 commits into from
Nov 14, 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
1 change: 1 addition & 0 deletions demo/lib/demo_web/live/post_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ defmodule DemoWeb.PostLive do
body: %{
module: Backpex.Fields.Textarea,
label: "Body",
rows: 10,
except: [:index]
},
published: %{
Expand Down
2 changes: 2 additions & 0 deletions lib/backpex/fields/textarea.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule Backpex.Fields.Textarea do

## Options

* `:rows` - Optional integer number of visible text lines for the control. If it is not specified, the default value is 2.
* `:placeholder` - Optional placeholder value or function that receives the assigns.
* `:debounce` - Optional integer timeout value (in milliseconds), "blur" or function that receives the assigns.
* `:throttle` - Optional integer timeout value (in milliseconds) or function that receives the assigns.
Expand Down Expand Up @@ -34,6 +35,7 @@ defmodule Backpex.Fields.Textarea do
<BackpexForm.input
type="textarea"
field={@form[@name]}
rows={@field_options[:rows] || 2}
translate_error_fun={Backpex.Field.translate_error_fun(@field_options, assigns)}
phx-debounce={Backpex.Field.debounce(@field_options, assigns)}
phx-throttle={Backpex.Field.throttle(@field_options, assigns)}
Expand Down