Class: BootstrapFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
app/form_builders/bootstrap_form_builder.rb

Instance Method Summary collapse

Instance Method Details

#check_box(name) ⇒ Object



38
39
40
41
42
43
44
# File 'app/form_builders/bootstrap_form_builder.rb', line 38

def check_box(name)
  wrapper name do
     :label, class: 'checkbox' do
      super(name)
    end
  end
end

#errors_forObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/form_builders/bootstrap_form_builder.rb', line 4

def errors_for
  return "" if @object.errors.empty?

  messages = @object.errors.full_messages.map { |msg| (:li, msg) }.join
  sentence = I18n.t(
    "errors.messages.not_saved",
    :count => @object.errors.count,
    :resource => @object.class.model_name.human.downcase
  )

  html = <<-HTML
    <div class="alert alert-error">
      <p><b>#{sentence}</b></p>
      <ul>#{messages}</ul>
    </div>
  HTML

  html.html_safe
end

#submit(value = nil) ⇒ Object



46
47
48
49
50
# File 'app/form_builders/bootstrap_form_builder.rb', line 46

def submit(value=nil)
   :div, class: 'form-actions' do
    super value, class: 'btn btn-primary'
  end
end