Class: CCS::Components::GovUK::Field::Input::Textarea
- Inherits:
-
CCS::Components::GovUK::Field::Input
- Object
- Base
- CCS::Components::GovUK::Field
- CCS::Components::GovUK::Field::Input
- CCS::Components::GovUK::Field::Input::Textarea
- Defined in:
- lib/ccs/components/govuk/field/input/textarea.rb
Overview
GOV.UK Textarea
This helper is used for generating the textarea component from the GDS - Components - Textarea
Constant Summary collapse
- DEFAULT_ATTRIBUTES =
The default attributes for the textarea
{ class: 'govuk-textarea' }.freeze
Instance Method Summary collapse
-
#initialize(attribute:, content: nil, rows: 5, **options) ⇒ Textarea
constructor
A new instance of Textarea.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Textarea component.
Constructor Details
#initialize(attribute:, content: nil, rows: 5, **options) ⇒ Textarea
Returns a new instance of Textarea.
29 30 31 32 33 34 35 |
# File 'lib/ccs/components/govuk/field/input/textarea.rb', line 29 def initialize(attribute:, content: nil, rows: 5, **) super(attribute: attribute, **) @options[:attributes][:rows] ||= rows @content = @options[:model] ? @options[:model].send(attribute) : content end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Textarea component
41 42 43 44 45 46 47 48 49 |
# File 'lib/ccs/components/govuk/field/input/textarea.rb', line 41 def render super do if [:form] [:form].text_area(attribute, **[:attributes]) else context.text_area_tag(attribute, content, **[:attributes]) end end end |