Class: FormBootstrap::Builder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- FormBootstrap::Builder
- Defined in:
- lib/form-bootstrap/builder.rb
Instance Method Summary collapse
- #actions(&block) ⇒ Object
- #alert_message(title, *args) ⇒ Object
- #check_box(name, *args) ⇒ Object
-
#initialize(object_name, object, template, options, proc) ⇒ Builder
constructor
A new instance of Builder.
- #primary(name) ⇒ Object
Constructor Details
#initialize(object_name, object, template, options, proc) ⇒ Builder
Returns a new instance of Builder.
5 6 7 8 |
# File 'lib/form-bootstrap/builder.rb', line 5 def initialize(object_name, object, template, , proc) super @help_css = ([:help].try(:to_sym) == :block) ? 'help-block' : 'help-inline' end |
Instance Method Details
#actions(&block) ⇒ Object
40 41 42 43 44 |
# File 'lib/form-bootstrap/builder.rb', line 40 def actions(&block) content_tag :div, class: "actions" do block.call end end |
#alert_message(title, *args) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/form-bootstrap/builder.rb', line 50 def (title, *args) = args. css = [:class] || "alert-message error" if object.errors..any? content_tag :div, class: css do title end end end |
#check_box(name, *args) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/form-bootstrap/builder.rb', line 25 def check_box(name, *args) = args..symbolize_keys! content_tag :div, class: "clearfix#{(' error' if object.errors[name].any?)}" do content_tag(:div, class: 'input') do content_tag(:ul, class: 'inputs-list') do content_tag(:li) do args << .except(:label, :help) html = super(name, *args) + ' ' + content_tag(:span) { [:label] } label(name, html) end end end end end |
#primary(name) ⇒ Object
46 47 48 |
# File 'lib/form-bootstrap/builder.rb', line 46 def primary(name) submit name, class: 'btn primary' end |