Class: BootstrapFormBuilder::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- BootstrapFormBuilder::FormBuilder
- Defined in:
- lib/bootstrap_form_builder/form_builder.rb
Instance Attribute Summary collapse
-
#layout ⇒ Object
Returns the value of attribute layout.
Instance Method Summary collapse
- #actions ⇒ Object
- #check_box(method, *args) ⇒ Object
- #email_field(*args) ⇒ Object
-
#initialize(object_name, object, template, options, proc) ⇒ FormBuilder
constructor
A new instance of FormBuilder.
- #number_field(*args) ⇒ Object
- #password_field(*args) ⇒ Object
- #select(*args) ⇒ Object
- #submit(text = nil, *args) ⇒ Object
- #text_area(*args) ⇒ Object
- #text_field(*args) ⇒ Object
Constructor Details
#initialize(object_name, object, template, options, proc) ⇒ FormBuilder
Returns a new instance of FormBuilder.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 100 def initialize(object_name, object, template, , proc) [:html] ||= {} form_classes = StringList.new([:html][:class]) unless form_classes.include?('form') form_classes += 'form' layout = .delete(:layout).try(:to_sym) || BootstrapFormBuilder::FormBuilder.default_layout if layout.present? case layout when :horizontal form_classes -= 'form-inline' form_classes += 'form-horizontal' when :inline form_classes -= 'form-horizontal' form_classes += 'form-inline' end [:html][:class] = form_classes.to_s end end super end |
Instance Attribute Details
#layout ⇒ Object
Returns the value of attribute layout.
98 99 100 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 98 def layout @layout end |
Instance Method Details
#actions ⇒ Object
163 164 165 166 167 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 163 def actions() @template.content_tag(:div, class: 'form-actions') do yield end end |
#check_box(method, *args) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 133 def check_box(method, *args) args = ParsedArgs.new(*args) tooltip = args..delete(:tooltip) @template.content_tag(:div, class: "control-group") do @template.content_tag(:div, class: "controls") do @template.content_tag(:label, class: "checkbox") do super + method.to_s.titleize + (tooltip.present? ? help_icon(tooltip) : ''.html_safe) end end end end |
#email_field(*args) ⇒ Object
155 156 157 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 155 def email_field(*args) control_group(*args) { super } end |
#number_field(*args) ⇒ Object
147 148 149 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 147 def number_field(*args) control_group(*args) { super } end |
#password_field(*args) ⇒ Object
151 152 153 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 151 def password_field(*args) control_group(*args) { super } end |
#select(*args) ⇒ Object
129 130 131 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 129 def select(*args) control_group(*args) { super } end |
#submit(text = nil, *args) ⇒ Object
169 170 171 172 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 169 def submit(text=nil, *args) = args. super(text || .delete(:submit_text), merge_classes(, "btn btn-primary")) end |
#text_area(*args) ⇒ Object
159 160 161 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 159 def text_area(*args) control_group(*args) { super } end |
#text_field(*args) ⇒ Object
125 126 127 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 125 def text_field(*args) control_group(*args) { super } end |