formular 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -4
- data/CHANGELOG.md +29 -2
- data/README.md +5 -4
- data/formular.gemspec +1 -1
- data/lib/formular/attributes.rb +10 -21
- data/lib/formular/builders/basic.rb +4 -3
- data/lib/formular/builders/bootstrap3.rb +2 -1
- data/lib/formular/builders/bootstrap4.rb +4 -4
- data/lib/formular/element.rb +54 -23
- data/lib/formular/element/bootstrap3.rb +40 -8
- data/lib/formular/element/bootstrap3/checkable_control.rb +5 -8
- data/lib/formular/element/bootstrap3/horizontal.rb +7 -7
- data/lib/formular/element/bootstrap3/input_group.rb +2 -2
- data/lib/formular/element/bootstrap4.rb +17 -8
- data/lib/formular/element/bootstrap4/checkable_control.rb +5 -4
- data/lib/formular/element/bootstrap4/custom_control.rb +8 -4
- data/lib/formular/element/bootstrap4/horizontal.rb +3 -3
- data/lib/formular/element/bootstrap4/input_group.rb +12 -0
- data/lib/formular/element/foundation6.rb +5 -5
- data/lib/formular/element/foundation6/checkable_control.rb +2 -4
- data/lib/formular/element/foundation6/input_group.rb +2 -2
- data/lib/formular/element/foundation6/{wrapped_control.rb → wrapped.rb} +4 -4
- data/lib/formular/element/modules/checkable.rb +10 -11
- data/lib/formular/element/modules/control.rb +12 -4
- data/lib/formular/element/modules/error.rb +6 -1
- data/lib/formular/element/modules/escape_value.rb +14 -0
- data/lib/formular/element/modules/hint.rb +5 -3
- data/lib/formular/element/modules/label.rb +5 -2
- data/lib/formular/element/modules/{wrapped_control.rb → wrapped.rb} +14 -13
- data/lib/formular/elements.rb +62 -19
- data/lib/formular/helper.rb +18 -4
- data/lib/formular/html_block.rb +1 -1
- data/lib/formular/html_escape.rb +19 -0
- data/lib/formular/path.rb +1 -6
- data/lib/formular/version.rb +1 -1
- metadata +16 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e07c2e8826a8660e76871f7c8796643f2ce14af6
|
4
|
+
data.tar.gz: 5d890ae78955fe7e751c441eb52ef817d73822e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66b87984f1027e268b7af86abb863c40f3f55b0c7bbbe1c973ad98b27a200d34961b5c8113fd2fa1c7311cd691be10140c2bc3c28d202008217b07937691c86f
|
7
|
+
data.tar.gz: c1f1f2f559011007f56f9f3d3c7efebf87716c11c921f5cf039384d37db7867ee58ea5657fd9c9676a3cc4e729d1a8ea7646a4fadab9bc21a1e24c07044ce4ab
|
data/.travis.yml
CHANGED
@@ -7,17 +7,18 @@ script:
|
|
7
7
|
rvm:
|
8
8
|
- 2.0
|
9
9
|
- 2.1.10
|
10
|
-
- 2.2.
|
11
|
-
- 2.3.
|
10
|
+
- 2.2.7
|
11
|
+
- 2.3.4
|
12
|
+
- 2.4.1
|
12
13
|
- rbx-2
|
13
|
-
- jruby-9.1.
|
14
|
+
- jruby-9.1.13.0
|
14
15
|
- ruby-head
|
15
16
|
env:
|
16
17
|
global:
|
17
18
|
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
18
19
|
matrix:
|
19
20
|
allow_failures:
|
20
|
-
- rvm: jruby-9.1.
|
21
|
+
- rvm: jruby-9.1.13.0
|
21
22
|
- rvm: rbx-2
|
22
23
|
- rvm: ruby-head
|
23
24
|
- rvm: jruby-head
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
# Master
|
2
|
+
|
3
|
+
# v0.2.2 2017-09-13
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
* Select elements prompt and include_blank options now operate the same way as simple form
|
8
|
+
* added procces_option to the Element API
|
9
|
+
* Checkboxes now support `checked_value` option as an alias of `value`. Same as SimpleForm.
|
10
|
+
* you can now set your own builders as the default in the helper
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
|
14
|
+
* Escape html (controls, labels errors hints) (fixes #29)
|
15
|
+
* setting a default builder in the helper now actually works!
|
16
|
+
* Select elements appends array signifier (`[]`) to element name attribute when `multiple: true` (fixes #40)
|
17
|
+
* options should always override default values, even when nil. (fixes #39)
|
18
|
+
|
19
|
+
### Internal
|
20
|
+
|
21
|
+
* element#options now includes both elements and html attributes
|
22
|
+
* elements#attributes only includes html attributes and can't be mutated. Change element#options instead
|
23
|
+
* elements#normalize_options no longer tries to use the default value if an option is present
|
24
|
+
* added a module for html_escape
|
25
|
+
* renamed WrappedControl module to Wrapped and stopped including control
|
26
|
+
* changes the order of default_hash to better respect inheritance ordering
|
27
|
+
* provide an element module for easily escaping html values
|
28
|
+
|
1
29
|
# v0.2.1 2016-09-29
|
2
30
|
|
3
31
|
### Fixed
|
@@ -5,7 +33,6 @@
|
|
5
33
|
* Correctly require declarative heritage for Formular::Element::Module - (@fran-worley)
|
6
34
|
* Update readme & include example gemgem links - (@fran-worley)
|
7
35
|
|
8
|
-
|
9
36
|
# v0.2.0 2016-09-27
|
10
37
|
|
11
|
-
First public release
|
38
|
+
First public release
|
data/README.md
CHANGED
@@ -60,9 +60,10 @@ Our basic builder ships with the following elements:
|
|
60
60
|
We also provide builders for Twitter Bootstrap (v.3&4) and Zurb's Foundation (v.6)
|
61
61
|
|
62
62
|
To help you get started we've got some example Sinatra apps so you can see Formular in action:
|
63
|
-
|
64
|
-
[
|
65
|
-
|
63
|
+
|
64
|
+
* [Bootstrap3 (slim)](https://github.com/fran-worley/gemgem-sinatra/blob/formular-slim-bootstrap3/concepts/post/view/new.slim)
|
65
|
+
* [Bootstrap4 (slim)](https://github.com/fran-worley/gemgem-sinatra/blob/formular-slim-bootstrap4/concepts/post/view/new.slim)
|
66
|
+
* Foundation6 (slim)
|
66
67
|
|
67
68
|
Formular's API docs and information on how to extend it will be found on the [Trailblazer project page](http://trailblazer.to/gems/formular) once the page has been added 😉.
|
68
69
|
|
@@ -75,7 +76,7 @@ Formular's API docs and information on how to extend it will be found on the [Tr
|
|
75
76
|
|
76
77
|
## Limitations
|
77
78
|
|
78
|
-
*
|
79
|
+
* Nested hashes aren't suffixed with active records `_attributes`.
|
79
80
|
* Capturing only works with Slim and Hamlit. A 'blockless' API is provided to enable use in ERB but watch this space as improvements are coming for ERB
|
80
81
|
|
81
82
|
## Installation
|
data/formular.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "declarative", '~> 0.0.4'
|
22
|
-
spec.add_dependency "uber", "
|
22
|
+
spec.add_dependency "uber", ">= 0.0.11", "< 0.2.0"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/formular/attributes.rb
CHANGED
@@ -5,32 +5,17 @@ module Formular
|
|
5
5
|
super
|
6
6
|
end
|
7
7
|
|
8
|
-
def merge(hash)
|
9
|
-
dup.merge!(hash)
|
10
|
-
end
|
11
|
-
|
12
|
-
def merge!(hash)
|
13
|
-
classes = self[:class]
|
14
|
-
new_classes = hash[:class]
|
15
|
-
return super unless classes && new_classes
|
16
|
-
|
17
|
-
hash[:class] += classes
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
8
|
# converts the hash into a string k1=v1 k2=v2
|
22
9
|
# replaces underscores with - so we can use regular keys
|
23
|
-
# allows one layer of
|
10
|
+
# allows one layer of nested hashes so we can define data options as a hash.
|
24
11
|
def to_html
|
25
|
-
map
|
26
|
-
if
|
27
|
-
|
28
|
-
%(#{key_to_attr_name(key)}-#{key_to_attr_name(k)}="#{val_to_string(v)}")
|
29
|
-
end.join(" ")
|
12
|
+
map { |key, value|
|
13
|
+
if value.is_a?(Hash)
|
14
|
+
value.map { |k,v| %(#{key_to_attr_name(key)}-#{attribute_html(k, v)}) }.join(' ')
|
30
15
|
else
|
31
|
-
|
16
|
+
attribute_html(key, value)
|
32
17
|
end
|
33
|
-
|
18
|
+
}.join(' ')
|
34
19
|
end
|
35
20
|
|
36
21
|
private
|
@@ -41,5 +26,9 @@ module Formular
|
|
41
26
|
def val_to_string(value)
|
42
27
|
value.is_a?(Array) ? value.join(' ') : value
|
43
28
|
end
|
29
|
+
|
30
|
+
def attribute_html(key, value)
|
31
|
+
%(#{key_to_attr_name(key)}="#{val_to_string(value)}")
|
32
|
+
end
|
44
33
|
end # class Attributes
|
45
34
|
end # module Formular
|
@@ -28,13 +28,14 @@ module Formular
|
|
28
28
|
error_wrapper: Formular::Element::Div
|
29
29
|
)
|
30
30
|
|
31
|
-
def initialize(model: nil, path_prefix: nil, errors: nil, elements: {})
|
31
|
+
def initialize(model: nil, path_prefix: nil, errors: nil, values: nil, elements: {})
|
32
32
|
@model = model
|
33
33
|
@path_prefix = path_prefix
|
34
34
|
@errors = errors || (model ? model.errors : {})
|
35
|
+
@values = values || {}
|
35
36
|
super(elements)
|
36
37
|
end
|
37
|
-
attr_reader :model, :errors
|
38
|
+
attr_reader :model, :errors, :values
|
38
39
|
|
39
40
|
def collection(name, models: nil, builder: nil, &block)
|
40
41
|
models ||= model ? model.send(name) : []
|
@@ -57,7 +58,7 @@ module Formular
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def reader_value(name)
|
60
|
-
model ? model.send(name) :
|
61
|
+
model ? model.send(name) : values[name.to_sym]
|
61
62
|
end
|
62
63
|
end # class Basic
|
63
64
|
end # module Builders
|
@@ -21,7 +21,8 @@ module Formular
|
|
21
21
|
wrapper: Formular::Element::Bootstrap3::Wrapper,
|
22
22
|
error_wrapper: Formular::Element::Bootstrap3::ErrorWrapper,
|
23
23
|
submit: Formular::Element::Bootstrap3::Submit,
|
24
|
-
row: Formular::Element::Bootstrap3::Row
|
24
|
+
row: Formular::Element::Bootstrap3::Row,
|
25
|
+
icon: Formular::Element::Bootstrap3::Icon
|
25
26
|
)
|
26
27
|
end # class Bootstrap3
|
27
28
|
end # module Builders
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'formular/builders/basic'
|
2
2
|
require 'formular/element/bootstrap4'
|
3
3
|
require 'formular/element/bootstrap3'
|
4
|
-
require 'formular/element/
|
4
|
+
require 'formular/element/bootstrap4/input_group'
|
5
5
|
|
6
6
|
module Formular
|
7
7
|
module Builders
|
@@ -11,10 +11,10 @@ module Formular
|
|
11
11
|
error: Formular::Element::Bootstrap4::Error,
|
12
12
|
hint: Formular::Element::Bootstrap4::Hint,
|
13
13
|
input: Formular::Element::Bootstrap4::Input,
|
14
|
-
input_group: Formular::Element::
|
14
|
+
input_group: Formular::Element::Bootstrap4::InputGroup,
|
15
15
|
checkbox: Formular::Element::Bootstrap4::StackedCheckbox,
|
16
16
|
radio: Formular::Element::Bootstrap4::StackedRadio,
|
17
|
-
select: Formular::Element::
|
17
|
+
select: Formular::Element::Bootstrap4::Select,
|
18
18
|
custom_select: Formular::Element::Bootstrap4::CustomSelect,
|
19
19
|
custom_file: Formular::Element::Bootstrap4::CustomFile,
|
20
20
|
custom_radio: Formular::Element::Bootstrap4::Inline::CustomRadio,
|
@@ -25,7 +25,7 @@ module Formular
|
|
25
25
|
inline_checkbox: Formular::Element::Bootstrap4::InlineCheckbox,
|
26
26
|
label: Formular::Element::Label,
|
27
27
|
checkable_group_label: Formular::Element::Legend,
|
28
|
-
textarea: Formular::Element::
|
28
|
+
textarea: Formular::Element::Bootstrap4::Textarea,
|
29
29
|
wrapper: Formular::Element::Bootstrap4::Wrapper,
|
30
30
|
error_wrapper: Formular::Element::Bootstrap4::ErrorWrapper,
|
31
31
|
submit: Formular::Element::Bootstrap4::Submit,
|
data/lib/formular/element.rb
CHANGED
@@ -13,10 +13,12 @@ module Formular
|
|
13
13
|
inheritable_attr :html_context
|
14
14
|
inheritable_attr :html_blocks
|
15
15
|
inheritable_attr :default_hash
|
16
|
+
inheritable_attr :processing_hash
|
16
17
|
inheritable_attr :option_keys
|
17
18
|
inheritable_attr :tag_name
|
18
19
|
|
19
20
|
self.default_hash = {}
|
21
|
+
self.processing_hash = {}
|
20
22
|
self.html_blocks = {}
|
21
23
|
self.html_context = :default
|
22
24
|
self.option_keys = []
|
@@ -24,10 +26,21 @@ module Formular
|
|
24
26
|
# set the default value of an option or attribute
|
25
27
|
# you can make this conditional by providing a condition
|
26
28
|
# e.g. if: :some_method or unless: :some_method
|
29
|
+
# to respect the order defaults are declared, rather than overriting existing defaults
|
30
|
+
# we should delete the existing and create a new k/v pair
|
27
31
|
def self.set_default(key, value, condition = {})
|
32
|
+
self.default_hash.delete(key) # attempt to delete an existing key
|
28
33
|
self.default_hash[key] = { value: value, condition: condition }
|
29
34
|
end
|
30
35
|
|
36
|
+
# process an option value (i.e. escape html)
|
37
|
+
# This occurs after the value has been set (either by default or by user input)
|
38
|
+
# you can make this conditional by providing a condition
|
39
|
+
# e.g. if: :some_method or unless: :some_method
|
40
|
+
def self.process_option(key, processor, condition = {})
|
41
|
+
self.processing_hash[key] = { processor: processor, condition: condition }
|
42
|
+
end
|
43
|
+
|
31
44
|
# define what your html should look like
|
32
45
|
# this block is executed in the context of an HtmlBlock instance
|
33
46
|
def self.html(context = :default, &block)
|
@@ -63,12 +76,19 @@ module Formular
|
|
63
76
|
|
64
77
|
def initialize(**options, &block)
|
65
78
|
@builder = options.delete(:builder)
|
66
|
-
|
79
|
+
@options = options
|
80
|
+
normalize_options
|
81
|
+
process_options
|
67
82
|
@block = block
|
68
83
|
@tag = self.class.tag_name
|
69
84
|
@html_blocks = define_html_blocks
|
70
85
|
end
|
71
|
-
attr_reader :tag, :html_blocks, :builder, :
|
86
|
+
attr_reader :tag, :html_blocks, :builder, :options
|
87
|
+
|
88
|
+
def attributes
|
89
|
+
attrs = @options.select { |k, v| @options[k] || true unless option_key?(k) }
|
90
|
+
Attributes[attrs]
|
91
|
+
end
|
72
92
|
|
73
93
|
def to_html(context: nil)
|
74
94
|
context ||= self.class.html_context
|
@@ -84,32 +104,43 @@ module Formular
|
|
84
104
|
end
|
85
105
|
end
|
86
106
|
|
87
|
-
#
|
88
|
-
#
|
89
|
-
# we then get the default_hash from the class
|
90
|
-
# and merge with the user options and attributes
|
91
|
-
def normalize_attributes(**options)
|
92
|
-
@attributes = Attributes[options]
|
93
|
-
@options = @attributes.select { |k, v| @attributes.delete(k) || true if option_key?(k) }
|
94
|
-
merge_default_hash
|
95
|
-
end
|
96
|
-
|
97
|
-
# Take each default value and merge it with attributes && options.
|
107
|
+
# Options passed into our element instance (@options) take precident over class level defaults
|
108
|
+
# Take each default value and merge it with options.
|
98
109
|
# This way ordering is important and we can access values as they are evaluated
|
99
|
-
def
|
100
|
-
self.class.default_hash.each do |
|
101
|
-
|
110
|
+
def normalize_options
|
111
|
+
self.class.default_hash.each do |key, hash|
|
112
|
+
should_merge = key.to_s.include?('class') && !options[key].nil?
|
113
|
+
|
114
|
+
next if options.has_key?(key) && !should_merge
|
102
115
|
|
103
|
-
|
116
|
+
# if our default is conditional and the condition evaluates to false then skip
|
117
|
+
next unless evaluate_option_condition?(hash[:condition])
|
104
118
|
|
119
|
+
val = Uber::Options::Value.new(hash[:value]).evaluate(self)
|
120
|
+
|
121
|
+
# if our default value is nil then skip
|
105
122
|
next if val.nil?
|
106
123
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
124
|
+
# otherwise perform the actual merge, classes get joined, otherwise we overwrite
|
125
|
+
should_merge ? @options[key] += val : @options[key] = val
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Options passed into our element instance (@options) take precident over class level defaults
|
130
|
+
# Take each default value and merge it with options.
|
131
|
+
# This way ordering is important and we can access values as they are evaluated
|
132
|
+
def process_options
|
133
|
+
self.class.processing_hash.each do |key, hash|
|
134
|
+
# we can't process if our option is nil
|
135
|
+
next if options[key].nil?
|
136
|
+
# don't process if our condition is false
|
137
|
+
next unless evaluate_option_condition?(hash[:condition])
|
138
|
+
|
139
|
+
# get our value
|
140
|
+
val = self.send(hash[:processor], options[key]) # TODO enable procs and blocks
|
141
|
+
|
142
|
+
# set our value
|
143
|
+
@options[key] = val
|
113
144
|
end
|
114
145
|
end
|
115
146
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'formular/element'
|
2
2
|
require 'formular/elements'
|
3
|
-
require 'formular/element/modules/
|
3
|
+
require 'formular/element/modules/wrapped'
|
4
4
|
require 'formular/element/module'
|
5
5
|
require 'formular/element/bootstrap3/checkable_control'
|
6
6
|
require 'formular/element/bootstrap3/column_control'
|
@@ -13,6 +13,39 @@ module Formular
|
|
13
13
|
Label = Class.new(Formular::Element::Label) { set_default :class, ['control-label'] }
|
14
14
|
Row = Class.new(Formular::Element::Div) { set_default :class, ['row'] }
|
15
15
|
|
16
|
+
class Icon < Formular::Element::Span
|
17
|
+
add_option_keys :name
|
18
|
+
set_default :class, :icon_class
|
19
|
+
|
20
|
+
#returns the class of the bootstrap Glyphicons
|
21
|
+
#accepts the string or symbolized name of the glyphicon (see list below for available options)
|
22
|
+
#asterisk, plus, euro, minus, cloud, envelope, pencil, glass, music, search, heart, star, star-empty,
|
23
|
+
#user, film, th-large, th, th-list, ok, remove, zoom-in, zoom-out, off, signal, cog, trash, home, file,
|
24
|
+
#time, road, download-alt, download, upload, inbox, play-circle, repeat, refresh, list-alt, lock,
|
25
|
+
#flag, headphones, volume-off, volume-down, volume-up, qrcode, barcode, tag, tags, book, bookmark,
|
26
|
+
#print, camera, font, bold, italic, text-height, text-width, align-left, align-center, align-right,
|
27
|
+
#align-justify, list, indent-left, indent-right, facetime-video, picture, map-marker, adjust,
|
28
|
+
#tint, edit, share, check, move, step-backward, fast-backward, backward, play, pause, stop, forward,
|
29
|
+
#fast-forward, step-forward, eject, chevron-left, chevron-right, plus-sign, minus-sign, remove-sign,
|
30
|
+
#ok-sign, question-sign, info-sign, screenshot, remove-circle, ok-circle, ban-circle, arrow-left,
|
31
|
+
#arrow-right, arrow-up, arrow-down, share-alt, resize-full, resize-small, exclamation-sign, gift, leaf,
|
32
|
+
#fire, eye-open, eye-close, warning-sign, plane, calendar, random, comment, magnet, chevron-up,
|
33
|
+
#chevron-down, retweet, shopping-cart, folder-close, folder-open, resize-vertical, resize-horizontal,
|
34
|
+
#hdd, bullhorn, bell, certificate, thumbs-up, thumbs-down, hand-right, hand-left, hand-up, hand-down,
|
35
|
+
#circle-arrow-right, circle-arrow-left, circle-arrow-up, circle-arrow-down, globe, wrench, tasks,
|
36
|
+
#filter, briefcase, fullscreen, dashboard, paperclip, heart-empty, link, phone, pushpin, usd, gbp,
|
37
|
+
#sort, sort-by-alphabet, sort-by-alphabet-alt, sort-by-order, sort-by-order-alt, sort-by-attributes,
|
38
|
+
#sort-by-attributes-alt, unchecked, expand, collapse-down, collapse-up, log-in, flash, log-out, new-window,
|
39
|
+
#record, save, open, saved, import, export, send, floppy-disk, floppy-saved, floppy-remove, floppy-save,
|
40
|
+
#floppy-open, credit-card, transfer, cutlery, header, compressed, earphone, phone-alt, tower, stats,
|
41
|
+
#sd-video, hd-video, subtitles, sound-stereo, sound-dolby, sound-5-1, sound-6-1, sound-7-1,
|
42
|
+
#copyright-mark, registration-mark, cloud-download, cloud-upload, tree-conifer, tree-deciduous
|
43
|
+
def icon_class
|
44
|
+
icon_name = options[:name].to_s.gsub("_","-")
|
45
|
+
%(glyphicon glyphicon-#{icon_name})
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
16
49
|
class Submit < Formular::Element::Button
|
17
50
|
set_default :class, ['btn', 'btn-default']
|
18
51
|
set_default :type, 'submit'
|
@@ -21,7 +54,6 @@ module Formular
|
|
21
54
|
class ErrorNotification < Formular::Element::ErrorNotification
|
22
55
|
set_default :class, ['alert alert-danger']
|
23
56
|
set_default :role, 'alert'
|
24
|
-
|
25
57
|
end
|
26
58
|
|
27
59
|
class Error < Formular::Element::Error
|
@@ -34,25 +66,25 @@ module Formular
|
|
34
66
|
end # class Hint
|
35
67
|
|
36
68
|
class Input < Formular::Element::Input
|
37
|
-
include Formular::Element::Modules::
|
69
|
+
include Formular::Element::Modules::Wrapped
|
38
70
|
include Formular::Element::Bootstrap3::ColumnControl
|
39
71
|
|
40
|
-
set_default :class,
|
72
|
+
set_default :class, :input_class
|
41
73
|
|
42
|
-
def
|
43
|
-
|
74
|
+
def input_class
|
75
|
+
'form-control' unless options[:type].to_s == 'file'
|
44
76
|
end
|
45
77
|
end # class Input
|
46
78
|
|
47
79
|
class Select < Formular::Element::Select
|
48
|
-
include Formular::Element::Modules::
|
80
|
+
include Formular::Element::Modules::Wrapped
|
49
81
|
include Formular::Element::Bootstrap3::ColumnControl
|
50
82
|
|
51
83
|
set_default :class, ['form-control']
|
52
84
|
end # class Select
|
53
85
|
|
54
86
|
class Textarea < Formular::Element::Textarea
|
55
|
-
include Formular::Element::Modules::
|
87
|
+
include Formular::Element::Modules::Wrapped
|
56
88
|
include Formular::Element::Bootstrap3::ColumnControl
|
57
89
|
|
58
90
|
set_default :class, ['form-control']
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'formular/elements'
|
2
|
-
require 'formular/element/modules/
|
2
|
+
require 'formular/element/modules/wrapped'
|
3
3
|
require 'formular/element/module'
|
4
4
|
|
5
5
|
module Formular
|
@@ -26,7 +26,7 @@ module Formular
|
|
26
26
|
end # class InlineCheckable
|
27
27
|
|
28
28
|
class InlineRadio < Formular::Element::Radio
|
29
|
-
include Formular::Element::Modules::
|
29
|
+
include Formular::Element::Modules::Wrapped
|
30
30
|
include InlineCheckable
|
31
31
|
|
32
32
|
add_option_keys :control_label_options
|
@@ -38,11 +38,10 @@ module Formular
|
|
38
38
|
end# class InlineRadio
|
39
39
|
|
40
40
|
class InlineCheckbox < Formular::Element::Checkbox
|
41
|
-
include Formular::Element::Modules::
|
41
|
+
include Formular::Element::Modules::Wrapped
|
42
42
|
include InlineCheckable
|
43
43
|
|
44
44
|
set_default :control_label_options, { class: ['checkbox-inline'] }
|
45
|
-
set_default :value, '1' # instead of reader value
|
46
45
|
|
47
46
|
html { closed_start_tag }
|
48
47
|
end # class InlineCheckbox
|
@@ -75,11 +74,9 @@ module Formular
|
|
75
74
|
end # module StackedCheckable
|
76
75
|
|
77
76
|
class Checkbox < Formular::Element::Checkbox
|
78
|
-
include Formular::Element::Modules::
|
77
|
+
include Formular::Element::Modules::Wrapped
|
79
78
|
include StackedCheckable
|
80
79
|
|
81
|
-
set_default :value, '1' # instead of reader value
|
82
|
-
|
83
80
|
html { closed_start_tag }
|
84
81
|
|
85
82
|
def inner_wrapper_class
|
@@ -88,7 +85,7 @@ module Formular
|
|
88
85
|
end # class Checkbox
|
89
86
|
|
90
87
|
class Radio < Formular::Element::Radio
|
91
|
-
include Formular::Element::Modules::
|
88
|
+
include Formular::Element::Modules::Wrapped
|
92
89
|
include StackedCheckable
|
93
90
|
|
94
91
|
def inner_wrapper_class
|