Sha256: bd992b73a839aaf5d0e25ffba430cb3629fc547995d9388b5f3071fbb5dbfcb8

Contents?: true

Size: 707 Bytes

Versions: 5

Compression:

Stored size: 707 Bytes

Contents

class Forms::FormRenderer
  include ActionView::Helpers::FormTagHelper

  attr_accessor :output_buffer
  attr_reader :form, :submission, :template
  
  def initialize(form, submission, template)
    @form, @submission, @template = form, submission, template
  end
  
  def render
    form_tag(form.path) do
      concat form.fields.render(submission, template)
      concat default_submit_button unless has_submit_button?
    end
  end
  
  def protect_against_forgery?
    false
  end
  
private
  def has_submit_button?
    form.fields.flatten.any? { |f| f.is_a?(Forms::Fields::SubmitButton) }
  end
  
  def default_submit_button
    content_tag(:div, submit_tag("Submit"), :class => "submit")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wheelhouse-forms-1.2.2 app/renderers/forms/form_renderer.rb
wheelhouse-forms-1.2.1 app/renderers/forms/form_renderer.rb
wheelhouse-forms-1.2 app/renderers/forms/form_renderer.rb
wheelhouse-forms-1.1 app/renderers/forms/form_renderer.rb
wheelhouse-forms-1.0 app/renderers/forms/form_renderer.rb