bsforforms 0.1.0 → 0.1.1
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 +12 -1
- data/bsforforms.gemspec +1 -1
- data/lib/bsforforms/version.rb +1 -1
- data/lib/bsforforms.rb +56 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da0d1168b0eb0ecf57e0e6524cc2de4c4da447c2
|
4
|
+
data.tar.gz: 94bb3f328ff54fb2eb225c92bf35406629cf7116
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3e5231a77cd679f4d87903b59f7c6fbd0d5a75b91f44df9d84e1e2fd25fd02cf97efaeff7a44e77cd5af462a8fc7144d0c836a72d589ae853dc21a47d303a66
|
7
|
+
data.tar.gz: c93628694f0a593e9303e8ed07fa575f28ecfc6d923ca341502d0f0dfbb6f18770dc609e5da91172fc10f8f10587deb026e6e9dabbb3145b77d6b42f2477bc54
|
data/README.md
CHANGED
@@ -22,7 +22,18 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
In order to use this gem, just install BS4 with your favourite gem and then call our class in your forms like this:
|
26
|
+
|
27
|
+
|
28
|
+
<%= form_with(model: person, local: true, builder: BsFormBuilder) do |form| %>
|
29
|
+
|
30
|
+
then, you can use it, just like this:
|
31
|
+
|
32
|
+
<%= form.text_field :name, id: :person_name, label: "Label"%>
|
33
|
+
<%= form.text_field :lastname, id: :person_lastname, class="Your optional class"%>
|
34
|
+
<%= form.text_field :address, id: :person_address, small: "Your text here"%>
|
35
|
+
<%= form.number_field :age, id: :person_age%>
|
36
|
+
<%= form.submit "Enviar" %>
|
26
37
|
|
27
38
|
## Development
|
28
39
|
|
data/bsforforms.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["David"]
|
10
10
|
spec.email = ["info@pixelpro.es"]
|
11
11
|
|
12
|
-
spec.summary = %q{This is a gem, to simplify BS4 integration with form for.}
|
12
|
+
spec.summary = %q{This is a gem, to simplify BS4 integration with form for. Once you have BS4, you can have super simple forms. See README at github}
|
13
13
|
spec.description = %q{This is a gem, to simplify BS4 integration with form for.}
|
14
14
|
spec.homepage = "https://github.com/bypixelpro/bsforforms"
|
15
15
|
|
data/lib/bsforforms/version.rb
CHANGED
data/lib/bsforforms.rb
CHANGED
@@ -1,6 +1,60 @@
|
|
1
1
|
require "bsforforms/version"
|
2
2
|
|
3
3
|
module Bsforforms
|
4
|
-
|
5
|
-
|
4
|
+
class BsFormBuilder < ActionView::Helpers::FormBuilder
|
5
|
+
include ActionView::Helpers::TagHelper
|
6
|
+
include ActionView::Helpers::CaptureHelper
|
7
|
+
include ActionView::Helpers::TextHelper
|
8
|
+
|
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
|
6
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bsforforms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David
|
@@ -76,5 +76,6 @@ rubyforge_project:
|
|
76
76
|
rubygems_version: 2.6.13
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
|
-
summary: This is a gem, to simplify BS4 integration with form for.
|
79
|
+
summary: This is a gem, to simplify BS4 integration with form for. Once you have BS4,
|
80
|
+
you can have super simple forms. See README at github
|
80
81
|
test_files: []
|