Module: Maglev::Form::Inputs::Textarea

Included in:
FormBuilder
Defined in:
app/lib/maglev/form/inputs/textarea.rb

Instance Method Summary collapse

Instance Method Details

#textarea(method, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'app/lib/maglev/form/inputs/textarea.rb', line 7

def textarea(method, options = {})
  attributes = field_attributes(method)

  @template.render(Maglev::Uikit::Form::TextareaComponent.new(
                     label: options[:label].presence || attributes[:content],
                     name: attributes[:name],
                     options: textarea_component_options(method, options),
                     html_options: options[:html_options] || {}
                   ))
end

#textarea_component_options(method, options) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'app/lib/maglev/form/inputs/textarea.rb', line 18

def textarea_component_options(method, options)
  {
    value: object.public_send(method),
    rows: options[:rows],
    max_length: options[:max_length],
    placeholder: options[:placeholder],
    error: error_messages(method)
  }
end