Textarea
bin/rails g quicksilver_ui:form Textarea
Default
app_form_with url: "#" do |form|
form.textarea :description
end
Autogrow
app_form_with url: "#" do |form|
form.textarea :description, value: "Bypasses are devices that allow some people to dash from point A to point B very fast while other people dash from point B to point A very fast. People living at point C, being a point directly in between, are often given to wonder what's so great about point A that so many people from point B are so keen to get there, and what's so great about point B that so many people from point A are so keen to get there. They often wish that people would just once and for all work out where the hell they wanted to be.", autogrow: true
end
With rows
app_form_with url: "#" do |form|
form.textarea :description, rows: 8, value: "Bypasses are devices that allow some people to dash from point A to point B very fast while other people dash from point B to point A very fast. People living at point C, being a point directly in between, are often given to wonder what's so great about point A that so many people from point B are so keen to get there, and what's so great about point B that so many people from point A are so keen to get there. They often wish that people would just once and for all work out where the hell they wanted to be."
end
Implementation
# frozen_string_literal: true
class Form::Textarea < Form::Input
prop :rows, _Integer?, reader: :private
prop :autogrow, _Boolean, default: false, predicate: :private, reader: :private
def view_template
textarea(class: classes, **options_with_defaults) do
value
end
end
private
def default_classes = "ui-form-control"
def default_options
super.merge(rows:).tap do |opts|
if autogrow?
opts[:data] = (opts[:data] || {}).merge(
controller: "autogrow",
action: "input->autogrow#input"
)
end
end
end
end