bsforforms 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bsforforms.rb +58 -0
- data/lib/bsforforms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2909e153a11ec89fba6512f018a93c9f0eb25260
|
4
|
+
data.tar.gz: 849c43eb6c45daab92a102da232c61c77e3d6a1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01dd84a980844f6cd47a3649843a9246851a8e838fde997a256f9a87868b132bae4d95f2e615f51cdee54a2fb7aeb702450f8399353299cc828293ccaadc963b
|
7
|
+
data.tar.gz: 7c34d4ee565e126bb76d2adca9434d59c975947f732fb45da0936f710674e328386ceb7c4f47aa84f146f849f84f561cb1693199c1ef472a4c182cf888b9f6ef
|
data/lib/bsforforms.rb
CHANGED
@@ -1,5 +1,63 @@
|
|
1
1
|
require "bsforforms/version"
|
2
2
|
|
3
3
|
module Bsforforms
|
4
|
+
|
5
|
+
|
6
|
+
class BsFormBuilder < ActionView::Helpers::FormBuilder
|
7
|
+
include ActionView::Helpers::TagHelper
|
8
|
+
include ActionView::Helpers::CaptureHelper
|
9
|
+
include ActionView::Helpers::TextHelper
|
10
|
+
|
11
|
+
attr_accessor :output_buffer
|
12
|
+
|
13
|
+
#TEXT FIELD
|
14
|
+
def text_field(attribute, options={})
|
15
|
+
#metemos un label que lo sacamos del formulario
|
16
|
+
options[:label] ||=attribute
|
17
|
+
#Componemos nosotros un label si no lo tiene
|
18
|
+
label_text ||= options.delete(:label).to_s.titleize
|
19
|
+
#Ponemos una clase por defecto
|
20
|
+
options[:class] ||= "form-control"
|
21
|
+
#ponemos el small que sea
|
22
|
+
options[:small]
|
23
|
+
|
24
|
+
#Componemos el div a la Bootstrap
|
25
|
+
todoslosfields do
|
26
|
+
|
27
|
+
label(attribute, label_text) +
|
28
|
+
super(attribute, options) +
|
29
|
+
content_tag(:small, options[:small])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
#NUMBER FIELD
|
34
|
+
def number_field(attribute, options={})
|
35
|
+
options[:label] ||=attribute
|
36
|
+
label_text ||= options.delete(:label).to_s.titleize
|
37
|
+
options[:class] ||= "form-control"
|
38
|
+
options[:small]
|
39
|
+
|
40
|
+
todoslosfields do
|
41
|
+
|
42
|
+
label(attribute, label_text) +
|
43
|
+
super(attribute, options) +
|
44
|
+
content_tag(:small, options[:small])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def todoslosfields(options={}, &block)
|
49
|
+
content_tag(:div, capture(&block), class: "form-group")
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
#BUTTON SUBMIT
|
54
|
+
|
55
|
+
def submit(text, options={})
|
56
|
+
options[:class] ||= "btn btn-primary"
|
57
|
+
super(text, options)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
end
|
4
62
|
|
5
63
|
end
|
data/lib/bsforforms/version.rb
CHANGED