Class: Bsforforms::BsFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Includes:
ActionView::Helpers::CaptureHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
Defined in:
lib/bsforforms.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#output_bufferObject

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, options={})
        options[:label] ||=attribute
        label_text ||= options.delete(:label).to_s.titleize
        options[:class] ||= "form-control"
        options[:small] 
        
        todoslosfields do

        label(attribute, label_text) +  
            super(attribute, options) +
        (:small, options[:small])            
        end
end

#submit(text, options = {}) ⇒ Object

BUTTON SUBMIT



55
56
57
58
# File 'lib/bsforforms.rb', line 55

def submit(text, options={})
options[:class] ||= "btn btn-primary"
    super(text, options) 
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, options={})
    #metemos un label que lo sacamos del formulario
    options[:label] ||=attribute
    #Componemos nosotros un label si no lo tiene
    label_text ||= options.delete(:label).to_s.titleize
    #Ponemos una clase por defecto
    options[:class] ||= "form-control"
    #ponemos el small que sea
    options[:small] 
    
    #Componemos el div a la Bootstrap
    todoslosfields do
        
    label(attribute, label_text) +  
        super(attribute, options) +
    (:small, options[:small])            
    end
end

#todoslosfields(options = {}, &block) ⇒ Object



48
49
50
# File 'lib/bsforforms.rb', line 48

def todoslosfields(options={}, &block)
    (:div, capture(&block), class: "form-group")
end