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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32ee3ea71b68872b47edcb38b64ca2ab95c60797
4
- data.tar.gz: 74b8f6f55fd6090d78255c767c6c10b3a1f56056
3
+ metadata.gz: da0d1168b0eb0ecf57e0e6524cc2de4c4da447c2
4
+ data.tar.gz: 94bb3f328ff54fb2eb225c92bf35406629cf7116
5
5
  SHA512:
6
- metadata.gz: 65561fc63ffccea3203a27ada82bba470fd04a05b5d535506350bc91b4e051771271cff8eeb10fbd19b59d468ab08d4c7d6a40a494fbca3b7b2488750b67a6af
7
- data.tar.gz: f21107f131549d51919a8f14e7387b9464686e40462ce985df83555413cdc816bb2fcf9d828e9358a18e3937a748000d307268ce5238f37e8616b4dd35a952af
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
- TODO: Write usage instructions here
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
 
@@ -1,3 +1,3 @@
1
1
  module Bsforforms
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/bsforforms.rb CHANGED
@@ -1,6 +1,60 @@
1
1
  require "bsforforms/version"
2
2
 
3
3
  module Bsforforms
4
- # Your code goes here...
5
- puts "Hola desde mi Gema!"
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.0
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: []