Skip to content

Commit

Permalink
Merge pull request #665 from guoxinghuang/develop
Browse files Browse the repository at this point in the history
Add ‘rows' attribute to the textarea, with a default value of 2 rows.
  • Loading branch information
Flo0807 authored Nov 14, 2024
2 parents c962207 + abefad9 commit 9088586
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
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

0 comments on commit 9088586

Please sign in to comment.