Module: Maglev::Form::Inputs::Richtext

Defined in:
app/lib/maglev/form/inputs/richtext.rb

Instance Method Summary collapse

Instance Method Details

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



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

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

  @template.render(Maglev::Uikit::Form::RichtextComponent.new(
                     label: options[:label].presence || attributes[:content],
                     name: attributes[:name],
                     options: richtext_component_options(method, options),
                     html_options: richtext_component_html_options(options)
                   ))
end

#richtext_component_html_options(options) ⇒ Object



28
29
30
# File 'app/lib/maglev/form/inputs/richtext.rb', line 28

def richtext_component_html_options(options)
  options[:html_options] || {}
end

#richtext_component_options(method, options) ⇒ Object



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

def richtext_component_options(method, options)
  {
    value: options.key?(:value) ? options[:value] : object.public_send(method),
    placeholder: options[:placeholder],
    line_break: options[:line_break],
    edit_link_path: options[:edit_link_path],
    error: error_messages(method)
  }
end