bsforforms 0.1.2 → 0.1.3
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/README.md +4 -1
- data/lib/bsforforms/version.rb +1 -1
- data/lib/bsforforms.rb +0 -55
- 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: 0cd75baecfa293addd070769b89a79f5e0d314ac
|
4
|
+
data.tar.gz: 239a352a76ffb134ed2394a5815eab6f219735b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ac6ffb776faea72de58bfb34b51d09682882d86ac8692381af93db461951892462600e5b8ffefe55319a107e77dc534ab5228fc79ac649f85339f3efd1a0b8
|
7
|
+
data.tar.gz: 007929ee077653281bdbf47008093402e883b97bba997e3aa38ce28d617760a0152578ed97722dfc7135c513cb47f6072ea8047e47c0208b3b07625d5b35e964
|
data/README.md
CHANGED
@@ -21,6 +21,9 @@ Or install it yourself as:
|
|
21
21
|
$ gem install bsforforms
|
22
22
|
|
23
23
|
## Usage
|
24
|
+
Before using it, paste this at "config/application.rb"
|
25
|
+
config.autoload_paths += %W( #{config.root}/lib )
|
26
|
+
|
24
27
|
|
25
28
|
In order to use this gem, just install BS4 with your favourite gem and then call our class in your forms like this:
|
26
29
|
|
@@ -33,7 +36,7 @@ then, you can use it, just like this:
|
|
33
36
|
<%= form.text_field :lastname, id: :person_lastname, class="Your optional class"%>
|
34
37
|
<%= form.text_field :address, id: :person_address, small: "Your text here"%>
|
35
38
|
<%= form.number_field :age, id: :person_age%>
|
36
|
-
<%= form.submit "
|
39
|
+
<%= form.submit "Send" %>
|
37
40
|
|
38
41
|
## Development
|
39
42
|
|
data/lib/bsforforms/version.rb
CHANGED
data/lib/bsforforms.rb
CHANGED
@@ -1,60 +1,5 @@
|
|
1
1
|
require "bsforforms/version"
|
2
2
|
|
3
3
|
module Bsforforms
|
4
|
-
class BsFormBuilder < ActionView::Helpers::FormBuilder
|
5
|
-
include ActionView::Helpers::TagHelper
|
6
|
-
include ActionView::Helpers::CaptureHelper
|
7
|
-
include ActionView::Helpers::TextHelper
|
8
4
|
|
9
|
-
attr_accessor :output_buffer
|
10
|
-
|
11
|
-
#TEXT FIELD
|
12
|
-
def text_field(attribute, options={})
|
13
|
-
#metemos un label que lo sacamos del formulario
|
14
|
-
options[:label] ||=attribute
|
15
|
-
#Componemos nosotros un label si no lo tiene
|
16
|
-
label_text ||= options.delete(:label).to_s.titleize
|
17
|
-
#Ponemos una clase por defecto
|
18
|
-
options[:class] ||= "form-control"
|
19
|
-
#ponemos el small que sea
|
20
|
-
options[:small]
|
21
|
-
|
22
|
-
#Componemos el div a la Bootstrap
|
23
|
-
todoslosfields do
|
24
|
-
|
25
|
-
label(attribute, label_text) +
|
26
|
-
super(attribute, options) +
|
27
|
-
content_tag(:small, options[:small])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
#NUMBER FIELD
|
32
|
-
def number_field(attribute, options={})
|
33
|
-
options[:label] ||=attribute
|
34
|
-
label_text ||= options.delete(:label).to_s.titleize
|
35
|
-
options[:class] ||= "form-control"
|
36
|
-
options[:small]
|
37
|
-
|
38
|
-
todoslosfields do
|
39
|
-
|
40
|
-
label(attribute, label_text) +
|
41
|
-
super(attribute, options) +
|
42
|
-
content_tag(:small, options[:small])
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def todoslosfields(options={}, &block)
|
47
|
-
content_tag(:div, capture(&block), class: "form-group")
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
#BUTTON SUBMIT
|
52
|
-
|
53
|
-
def submit(text, options={})
|
54
|
-
options[:class] ||= "btn btn-primary"
|
55
|
-
super(text, options)
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
end
|
60
5
|
end
|