Class: Bsforforms::BsFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Bsforforms::BsFormBuilder
- Includes:
- ActionView::Helpers::CaptureHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
- Defined in:
- lib/bsforforms.rb
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
Instance Method Summary collapse
-
#number_field(attribute, options = {}) ⇒ Object
NUMBER FIELD.
-
#submit(text, options = {}) ⇒ Object
BUTTON SUBMIT.
-
#text_field(attribute, options = {}) ⇒ Object
TEXT FIELD.
- #todoslosfields(options = {}, &block) ⇒ Object
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
11 12 13 |
# File 'lib/bsforforms.rb', line 11 def output_buffer @output_buffer end |
Instance Method Details
#number_field(attribute, options = {}) ⇒ Object
NUMBER FIELD
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bsforforms.rb', line 34 def number_field(attribute, ={}) [:label] ||=attribute label_text ||= .delete(:label).to_s.titleize [:class] ||= "form-control" [:small] todoslosfields do label(attribute, label_text) + super(attribute, ) + content_tag(:small, [:small]) end end |
#submit(text, options = {}) ⇒ Object
BUTTON SUBMIT
55 56 57 58 |
# File 'lib/bsforforms.rb', line 55 def submit(text, ={}) [:class] ||= "btn btn-primary" super(text, ) end |
#text_field(attribute, options = {}) ⇒ Object
TEXT FIELD
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bsforforms.rb', line 14 def text_field(attribute, ={}) #metemos un label que lo sacamos del formulario [:label] ||=attribute #Componemos nosotros un label si no lo tiene label_text ||= .delete(:label).to_s.titleize #Ponemos una clase por defecto [:class] ||= "form-control" #ponemos el small que sea [:small] #Componemos el div a la Bootstrap todoslosfields do label(attribute, label_text) + super(attribute, ) + content_tag(:small, [:small]) end end |
#todoslosfields(options = {}, &block) ⇒ Object
48 49 50 |
# File 'lib/bsforforms.rb', line 48 def todoslosfields(={}, &block) content_tag(:div, capture(&block), class: "form-group") end |