Class: CaringForm::Field::Submit::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/caring_form/field/submit.rb

Instance Method Summary collapse

Constructor Details

#initialize(field, form, template, options) ⇒ Renderer

Returns a new instance of Renderer.



10
11
12
# File 'lib/caring_form/field/submit.rb', line 10

def initialize(field, form, template, options)
  @field, @form, @template, @options = field, form, template, options
end

Instance Method Details

#renderObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/caring_form/field/submit.rb', line 14

def render
  tag = @options[:wrapper_tag] || @field.wrapper_tag
  html_options = @options[:wrapper_html] || @field.wrapper_html.dup
  html_options[:class] = classes_from(html_options[:class], ['field'])
  wrap_content = @options.fetch(:wrapper, @field.wrapper.nil? ? true : @field.wrapper)
  if wrap_content
    @template.(tag, render_button.html_safe, html_options)
  else
    render_button
  end
end