formtastic_rebootstrap 0.0.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 +7 -0
- data/.document +5 -0
- data/LICENSE.txt +20 -0
- data/README.md +200 -0
- data/VERSION +1 -0
- data/lib/action_view/helpers/text_field_date_helper.rb +166 -0
- data/lib/formtastic_rebootstrap/actions/base.rb +27 -0
- data/lib/formtastic_rebootstrap/actions/button_action.rb +13 -0
- data/lib/formtastic_rebootstrap/actions/input_action.rb +13 -0
- data/lib/formtastic_rebootstrap/actions/link_action.rb +12 -0
- data/lib/formtastic_rebootstrap/actions.rb +10 -0
- data/lib/formtastic_rebootstrap/engine.rb +4 -0
- data/lib/formtastic_rebootstrap/form_builder.rb +45 -0
- data/lib/formtastic_rebootstrap/helpers/actions_helper.rb +24 -0
- data/lib/formtastic_rebootstrap/helpers/errors_helper.rb +70 -0
- data/lib/formtastic_rebootstrap/helpers/fieldset_wrapper.rb +35 -0
- data/lib/formtastic_rebootstrap/helpers/inputs_helper.rb +34 -0
- data/lib/formtastic_rebootstrap/helpers.rb +19 -0
- data/lib/formtastic_rebootstrap/inputs/base/choices.rb +20 -0
- data/lib/formtastic_rebootstrap/inputs/base/collections.rb +9 -0
- data/lib/formtastic_rebootstrap/inputs/base/datetime_pickerish.rb +10 -0
- data/lib/formtastic_rebootstrap/inputs/base/errors.rb +48 -0
- data/lib/formtastic_rebootstrap/inputs/base/hints.rb +27 -0
- data/lib/formtastic_rebootstrap/inputs/base/html.rb +36 -0
- data/lib/formtastic_rebootstrap/inputs/base/labelling.rb +40 -0
- data/lib/formtastic_rebootstrap/inputs/base/numeric.rb +9 -0
- data/lib/formtastic_rebootstrap/inputs/base/placeholder.rb +9 -0
- data/lib/formtastic_rebootstrap/inputs/base/stringish.rb +17 -0
- data/lib/formtastic_rebootstrap/inputs/base/timeish.rb +71 -0
- data/lib/formtastic_rebootstrap/inputs/base/wrapping.rb +83 -0
- data/lib/formtastic_rebootstrap/inputs/base.rb +45 -0
- data/lib/formtastic_rebootstrap/inputs/boolean_input.rb +51 -0
- data/lib/formtastic_rebootstrap/inputs/check_boxes_input.rb +41 -0
- data/lib/formtastic_rebootstrap/inputs/color_input.rb +15 -0
- data/lib/formtastic_rebootstrap/inputs/country_input.rb +14 -0
- data/lib/formtastic_rebootstrap/inputs/date_input.rb +10 -0
- data/lib/formtastic_rebootstrap/inputs/date_picker_input.rb +9 -0
- data/lib/formtastic_rebootstrap/inputs/date_select_input.rb +14 -0
- data/lib/formtastic_rebootstrap/inputs/datetime_input.rb +10 -0
- data/lib/formtastic_rebootstrap/inputs/datetime_picker_input.rb +9 -0
- data/lib/formtastic_rebootstrap/inputs/datetime_select_input.rb +8 -0
- data/lib/formtastic_rebootstrap/inputs/email_input.rb +15 -0
- data/lib/formtastic_rebootstrap/inputs/file_input.rb +14 -0
- data/lib/formtastic_rebootstrap/inputs/hidden_input.rb +12 -0
- data/lib/formtastic_rebootstrap/inputs/number_input.rb +15 -0
- data/lib/formtastic_rebootstrap/inputs/password_input.rb +15 -0
- data/lib/formtastic_rebootstrap/inputs/phone_input.rb +15 -0
- data/lib/formtastic_rebootstrap/inputs/radio_input.rb +47 -0
- data/lib/formtastic_rebootstrap/inputs/range_input.rb +15 -0
- data/lib/formtastic_rebootstrap/inputs/search_input.rb +15 -0
- data/lib/formtastic_rebootstrap/inputs/select_input.rb +16 -0
- data/lib/formtastic_rebootstrap/inputs/string_input.rb +8 -0
- data/lib/formtastic_rebootstrap/inputs/text_input.rb +14 -0
- data/lib/formtastic_rebootstrap/inputs/time_input.rb +10 -0
- data/lib/formtastic_rebootstrap/inputs/time_select_input.rb +14 -0
- data/lib/formtastic_rebootstrap/inputs/time_zone_input.rb +14 -0
- data/lib/formtastic_rebootstrap/inputs/url_input.rb +14 -0
- data/lib/formtastic_rebootstrap/inputs.rb +38 -0
- data/lib/formtastic_rebootstrap/version.rb +3 -0
- data/lib/formtastic_rebootstrap.rb +23 -0
- data/vendor/assets/stylesheets/formtastic_rebootstrap.css +7 -0
- metadata +218 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Helpers
|
3
|
+
module InputsHelper
|
4
|
+
|
5
|
+
def inputs(*args, &block)
|
6
|
+
wrap_it = @already_in_an_inputs_block ? true : false
|
7
|
+
@already_in_an_inputs_block = true
|
8
|
+
|
9
|
+
title = field_set_title_from_args(*args)
|
10
|
+
html_options = args.extract_options!
|
11
|
+
html_options[:class] ||= "inputs"
|
12
|
+
html_options[:name] = title
|
13
|
+
|
14
|
+
out = begin
|
15
|
+
if html_options[:for] # Nested form
|
16
|
+
inputs_for_nested_attributes(*(args << html_options), &block)
|
17
|
+
elsif block_given?
|
18
|
+
field_set_and_list_wrapping(*(args << html_options), &block)
|
19
|
+
else
|
20
|
+
legend = args.shift if args.first.is_a?(::String)
|
21
|
+
args = default_columns_for_object if @object && args.empty?
|
22
|
+
contents = fieldset_contents_from_column_list(args)
|
23
|
+
args.unshift(legend) if legend.present?
|
24
|
+
field_set_and_list_wrapping(*((args << html_options) << contents))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
@already_in_an_inputs_block = false
|
29
|
+
out
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Helpers
|
3
|
+
|
4
|
+
autoload :ActionsHelper, 'formtastic_rebootstrap/helpers/actions_helper'
|
5
|
+
autoload :ErrorsHelper, 'formtastic_rebootstrap/helpers/errors_helper'
|
6
|
+
autoload :FieldsetWrapper, 'formtastic_rebootstrap/helpers/fieldset_wrapper'
|
7
|
+
# autoload :FileColumnDetection, 'formtastic/helpers/file_column_detection'
|
8
|
+
# autoload :FormHelper, 'formtastic/helpers/form_helper'
|
9
|
+
autoload :InputsHelper, 'formtastic_rebootstrap/helpers/inputs_helper'
|
10
|
+
# autoload :LabelHelper, 'formtastic/helpers/label_helper'
|
11
|
+
# autoload :SemanticFormHelper, 'formtastic/helpers/semantic_form_helper'
|
12
|
+
# autoload :Reflection, 'formtastic/helpers/reflection'
|
13
|
+
|
14
|
+
def self.bootstrap_layout_classes_regex
|
15
|
+
/^col-(sm|md|lg|xl)?-?[0-9]{1,2}/
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
module Base
|
4
|
+
module Choices
|
5
|
+
include Formtastic::Inputs::Base::Choices
|
6
|
+
|
7
|
+
def choice_wrapping_html_options(choice)
|
8
|
+
super(choice).tap do |options|
|
9
|
+
options[:for] = choice_input_dom_id(choice)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def choice_label_html_options(choice)
|
14
|
+
choice_wrapping_html_options(choice)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
module Base
|
4
|
+
module Errors
|
5
|
+
|
6
|
+
include Formtastic::Inputs::Base::Errors
|
7
|
+
|
8
|
+
def error_html(inline_or_block = :inline)
|
9
|
+
errors? ? send(:"error_#{builder.inline_errors}_html", inline_or_block) : ""
|
10
|
+
end
|
11
|
+
|
12
|
+
def error_sentence_html(inline_or_block)
|
13
|
+
error_class = if inline_or_block == :inline
|
14
|
+
options[:error_class] || builder.default_inline_error_class
|
15
|
+
else
|
16
|
+
options[:error_class] || builder.default_block_error_class
|
17
|
+
end
|
18
|
+
template.content_tag(:span, Formtastic::Util.html_safe(errors.to_sentence.html_safe), :class => error_class)
|
19
|
+
end
|
20
|
+
|
21
|
+
def error_list_html(ignore)
|
22
|
+
super()
|
23
|
+
# error_class = options[:error_class] || builder.default_error_list_class
|
24
|
+
# list_elements = []
|
25
|
+
# errors.each do |error|
|
26
|
+
# list_elements << template.content_tag(:li, Formtastic::Util.html_safe(error.html_safe))
|
27
|
+
# end
|
28
|
+
# template.content_tag(:ul, Formtastic::Util.html_safe(list_elements.join("\n")), :class => error_class)
|
29
|
+
end
|
30
|
+
|
31
|
+
def error_first_html(inline_or_block = :inline)
|
32
|
+
error_class = if inline_or_block == :inline
|
33
|
+
options[:error_class] || builder.default_inline_error_class
|
34
|
+
else
|
35
|
+
options[:error_class] || builder.default_block_error_class
|
36
|
+
end
|
37
|
+
template.content_tag(:span, Formtastic::Util.html_safe(errors.first.untaint), :class => error_class)
|
38
|
+
end
|
39
|
+
|
40
|
+
def error_none_html(ignore)
|
41
|
+
# super
|
42
|
+
""
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
module Base
|
4
|
+
module Hints
|
5
|
+
|
6
|
+
include Formtastic::Inputs::Base::Hints
|
7
|
+
|
8
|
+
def hint_html(inline_or_block = :block)
|
9
|
+
if hint?
|
10
|
+
hint_class = if inline_or_block == :inline
|
11
|
+
options[:hint_class] || builder.default_inline_hint_class
|
12
|
+
else
|
13
|
+
options[:hint_class] || builder.default_block_hint_class
|
14
|
+
end
|
15
|
+
template.content_tag(
|
16
|
+
:span,
|
17
|
+
Formtastic::Util.html_safe(hint_text),
|
18
|
+
:class => hint_class
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
module Base
|
4
|
+
module Html
|
5
|
+
|
6
|
+
include Formtastic::Inputs::Base::Html
|
7
|
+
|
8
|
+
def form_control_input_html_options
|
9
|
+
new_classes = input_class_without_col&.compact&.join(" ")
|
10
|
+
input_html_options.merge(:class => new_classes)
|
11
|
+
end
|
12
|
+
|
13
|
+
def original_classes
|
14
|
+
input_html_options[:class]&.split(' ')&.flatten
|
15
|
+
end
|
16
|
+
|
17
|
+
def input_class_without_col
|
18
|
+
['form-control'] << original_classes&.reject do |c|
|
19
|
+
c.match(/^col-(sm|md|lg|xl)?-?[0-9]{1,2}/)
|
20
|
+
end&.join(' ')
|
21
|
+
end
|
22
|
+
|
23
|
+
def input_html_options
|
24
|
+
if errors?
|
25
|
+
{
|
26
|
+
:class => "error"
|
27
|
+
}.merge(super)
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
module Base
|
4
|
+
module Labelling
|
5
|
+
|
6
|
+
include Formtastic::Inputs::Base::Labelling
|
7
|
+
|
8
|
+
def label_html_options
|
9
|
+
super.tap do |options|
|
10
|
+
# Bootstrap defines class 'label' too, so remove the
|
11
|
+
# one that gets created by Formtastic.
|
12
|
+
options[:class] = options[:class].reject { |c| c == 'label' }
|
13
|
+
options[:class] << "control-label"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# def control_label_html
|
18
|
+
def label_html
|
19
|
+
if render_label?
|
20
|
+
template.content_tag(:span, :class => label_class_with_col) do
|
21
|
+
builder.label(input_name, label_text, label_html_options)
|
22
|
+
end
|
23
|
+
else
|
24
|
+
"".html_safe
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def layout_classes
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def label_class_with_col
|
33
|
+
['col-md-3 form-label col-form-label'] << options.dig(:label_html, :class)&.split(' ')&.select do |c|
|
34
|
+
c.match(/^col-(sm|md|lg|xl)?-?[0-9]{1,2}/)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
module Base
|
4
|
+
module Stringish
|
5
|
+
|
6
|
+
include Formtastic::Inputs::Base::Stringish
|
7
|
+
|
8
|
+
def to_html
|
9
|
+
bootstrap_wrapping do
|
10
|
+
builder.text_field(method, form_control_input_html_options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
module Base
|
4
|
+
module Timeish
|
5
|
+
FRAGMENT_CLASSES = {
|
6
|
+
:year => "col-xs-2",
|
7
|
+
:month => "col-xs-3",
|
8
|
+
:day => "col-xs-1",
|
9
|
+
:hour => "col-xs-offset-3 col-xs-1",
|
10
|
+
:minute => "col-xs-1",
|
11
|
+
:second => "col-xs-1"
|
12
|
+
}
|
13
|
+
|
14
|
+
FRAGMENT_PLACEHOLDERS = {
|
15
|
+
:year => nil,
|
16
|
+
:month => nil,
|
17
|
+
:day => nil,
|
18
|
+
:hour => nil,
|
19
|
+
:minute => nil,
|
20
|
+
:second => nil
|
21
|
+
}
|
22
|
+
|
23
|
+
def to_html
|
24
|
+
bootstrap_wrapping do
|
25
|
+
hidden_fragments <<
|
26
|
+
row_wrapping do
|
27
|
+
fragments.map do |fragment|
|
28
|
+
fragment_html(fragment.to_sym)
|
29
|
+
end.join.html_safe
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def row_wrapping(&block)
|
35
|
+
template.content_tag(:div,
|
36
|
+
template.capture(&block).html_safe,
|
37
|
+
:class => 'row md-pl-3'
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def fragment_html(fragment)
|
42
|
+
template.content_tag(:div, :class => fragment_class(fragment)) do
|
43
|
+
opts = input_options.merge(:prefix => fragment_prefix, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?)
|
44
|
+
template.send(:"select_#{fragment}", value, opts, fragment_input_html_options(fragment))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def fragment_input_html_options(fragment)
|
49
|
+
input_html_options.tap do |options|
|
50
|
+
options[:id] = fragment_id(fragment)
|
51
|
+
|
52
|
+
options[:class] = ((options[:class] || "").split.flatten.reject do |c|
|
53
|
+
c.match(Helpers.bootstrap_layout_classes_regex)
|
54
|
+
end << "form-control").join(" ")
|
55
|
+
|
56
|
+
options[:placeholder] = fragment_placeholder(fragment)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def fragment_class(fragment)
|
61
|
+
(options[:fragment_classes] || self.class::FRAGMENT_CLASSES)[fragment.to_sym]
|
62
|
+
end
|
63
|
+
|
64
|
+
def fragment_placeholder(fragment)
|
65
|
+
(options[:fragment_placeholders] || self.class::FRAGMENT_PLACEHOLDERS)[fragment.to_sym]
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
module Base
|
4
|
+
module Wrapping
|
5
|
+
|
6
|
+
include Formtastic::Inputs::Base::Wrapping
|
7
|
+
|
8
|
+
def bootstrap_wrapping(&block)
|
9
|
+
form_group_wrapping do
|
10
|
+
label_html <<
|
11
|
+
template.content_tag(:span, :class => wrapping_class_with_col&.uniq&.join(' ')) do
|
12
|
+
input_content(&block) <<
|
13
|
+
hint_html(:block) <<
|
14
|
+
error_html(:block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def input_options_classes
|
20
|
+
options.dig(:input_html, :class)&.split(' ')&.flatten
|
21
|
+
end
|
22
|
+
|
23
|
+
def input_default_col
|
24
|
+
'col-md-9'
|
25
|
+
end
|
26
|
+
|
27
|
+
def wrapping_class_with_col
|
28
|
+
return ['form-wrapper'] << input_default_col unless input_options_classes
|
29
|
+
options[:input_html][:class] = options.dig(:input_html, :class)&.split(' ')
|
30
|
+
['form-wrapper'] << input_options_classes&.select do |c|
|
31
|
+
c.match(/^col-(sm|md|lg|xl)?-?[0-9]{1,2}/)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def input_content(&block)
|
36
|
+
content = [
|
37
|
+
add_on_content(options[:prepend]),
|
38
|
+
options[:prepend_content],
|
39
|
+
yield,
|
40
|
+
add_on_content(options[:append]),
|
41
|
+
options[:append_content]
|
42
|
+
].compact.join("\n").html_safe
|
43
|
+
|
44
|
+
if prepended_or_appended?(options)
|
45
|
+
template.content_tag(:div, content, :class => add_on_wrapper_classes(options).join(" "))
|
46
|
+
else
|
47
|
+
content
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def prepended_or_appended?(options)
|
52
|
+
options[:prepend] || options[:prepend_content] || options[:append] || options[:append_content]
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_on_content(content)
|
56
|
+
return nil unless content
|
57
|
+
template.content_tag(:span, content, :class => 'input-group-addon')
|
58
|
+
end
|
59
|
+
|
60
|
+
def form_group_wrapping(&block)
|
61
|
+
template.content_tag(:div,
|
62
|
+
template.capture(&block).html_safe,
|
63
|
+
wrapper_html_options
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def wrapper_html_options
|
68
|
+
super.tap do |options|
|
69
|
+
options[:class] << " form-group form-row"
|
70
|
+
options[:class] << " has-error" if errors?
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def add_on_wrapper_classes(options)
|
75
|
+
[:prepend, :append, :prepend_content, :append_content].find do |key|
|
76
|
+
options.has_key?(key)
|
77
|
+
end ? ['input-group'] : []
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "formtastic_rebootstrap/inputs/base/errors"
|
2
|
+
require "formtastic_rebootstrap/inputs/base/hints"
|
3
|
+
require "formtastic_rebootstrap/inputs/base/html"
|
4
|
+
require "formtastic_rebootstrap/inputs/base/labelling"
|
5
|
+
|
6
|
+
module FormtasticRebootstrap
|
7
|
+
module Inputs
|
8
|
+
module Base
|
9
|
+
extend ActiveSupport::Autoload
|
10
|
+
|
11
|
+
autoload :DatetimePickerish, "formtastic_rebootstrap/inputs/base/datetime_pickerish"
|
12
|
+
# autoload :Associations
|
13
|
+
autoload :Collections, "formtastic_rebootstrap/inputs/base/collections"
|
14
|
+
autoload :Choices, "formtastic_rebootstrap/inputs/base/choices"
|
15
|
+
# autoload :Database
|
16
|
+
# autoload :Errors
|
17
|
+
# autoload :Fileish
|
18
|
+
# autoload :Hints
|
19
|
+
# autoload :Html
|
20
|
+
# autoload :Labelling
|
21
|
+
# autoload :Naming
|
22
|
+
autoload :Numeric, "formtastic_rebootstrap/inputs/base/numeric"
|
23
|
+
# autoload :Options
|
24
|
+
autoload :Placeholder, "formtastic_rebootstrap/inputs/base/placeholder"
|
25
|
+
autoload :Stringish, "formtastic_rebootstrap/inputs/base/stringish"
|
26
|
+
autoload :Timeish, "formtastic_rebootstrap/inputs/base/timeish"
|
27
|
+
# autoload :Validations
|
28
|
+
autoload :Wrapping, "formtastic_rebootstrap/inputs/base/wrapping"
|
29
|
+
|
30
|
+
include Html
|
31
|
+
# include Options
|
32
|
+
# include Database
|
33
|
+
# include Database
|
34
|
+
include Errors
|
35
|
+
include Hints
|
36
|
+
# include Naming
|
37
|
+
# include Validations
|
38
|
+
# include Fileish
|
39
|
+
# include Associations
|
40
|
+
include Labelling
|
41
|
+
include Wrapping
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# TODO See if this can be refactored to make use of some of the Choices code.
|
2
|
+
module FormtasticRebootstrap
|
3
|
+
module Inputs
|
4
|
+
class BooleanInput < Formtastic::Inputs::BooleanInput
|
5
|
+
include Base
|
6
|
+
|
7
|
+
# Skip rendering of .form-label in #bootstrap_wrapping
|
8
|
+
def render_label?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_html
|
13
|
+
bootstrap_wrapping do
|
14
|
+
hidden_field_html <<
|
15
|
+
check_box_html
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def hidden_field_html
|
20
|
+
template.hidden_field_tag(
|
21
|
+
input_html_options[:name],
|
22
|
+
unchecked_value,
|
23
|
+
:id => nil,
|
24
|
+
:disabled => input_html_options[:disabled]
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def label_with_nested_checkbox
|
29
|
+
builder.label(
|
30
|
+
method,
|
31
|
+
label_text_with_embedded_checkbox,
|
32
|
+
label_html_options
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def checkbox_wrapping(&block)
|
37
|
+
template.content_tag(:div,
|
38
|
+
template.capture(&block).html_safe,
|
39
|
+
wrapper_html_options
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def wrapper_html_options
|
44
|
+
super.tap do |options|
|
45
|
+
options[:class] = (options[:class].split + ["checkbox"]).join(" ")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
class CheckBoxesInput < Formtastic::Inputs::CheckBoxesInput
|
4
|
+
include Base
|
5
|
+
include Base::Choices
|
6
|
+
|
7
|
+
# TODO Make sure help blocks work correctly.
|
8
|
+
|
9
|
+
def to_html
|
10
|
+
bootstrap_wrapping do
|
11
|
+
hidden_field_for_all << # Might need to remove this guy.
|
12
|
+
collection.map { |choice|
|
13
|
+
choice_html(choice)
|
14
|
+
}.join("\n").html_safe
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def choice_html(choice)
|
19
|
+
checkbox_wrapping do
|
20
|
+
template.content_tag(:label,
|
21
|
+
hidden_fields? ?
|
22
|
+
check_box_with_hidden_input(choice) :
|
23
|
+
check_box_without_hidden_input(choice) <<
|
24
|
+
choice_label(choice),
|
25
|
+
label_html_options.merge(choice_label_html_options(choice))
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def checkbox_wrapping(&block)
|
31
|
+
class_name = "checkbox"
|
32
|
+
class_name += " checkbox-inline" if options[:inline]
|
33
|
+
template.content_tag(:div,
|
34
|
+
template.capture(&block).html_safe,
|
35
|
+
:class => class_name
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
class ColorInput < Formtastic::Inputs::ColorInput
|
4
|
+
include Base
|
5
|
+
include Base::Stringish
|
6
|
+
|
7
|
+
def to_html
|
8
|
+
raise "The :color input requires the color_field form helper, which is only available in Rails 4+" unless builder.respond_to?(:color_field)
|
9
|
+
bootstrap_wrapping do
|
10
|
+
builder.color_field(method, form_control_input_html_options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
class CountryInput < Formtastic::Inputs::CountryInput
|
4
|
+
include Base
|
5
|
+
|
6
|
+
def to_html
|
7
|
+
bootstrap_wrapping do
|
8
|
+
builder.country_select(method, priority_countries, input_options, form_control_input_html_options)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
class DateInput < FormtasticRebootstrap::Inputs::DateSelectInput
|
4
|
+
def to_html
|
5
|
+
::ActiveSupport::Deprecation.warn("DateInput (:as => :date) has been renamed to DateSelectInput (:as => :date_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2))
|
6
|
+
super
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
class DateSelectInput < Formtastic::Inputs::DateSelectInput
|
4
|
+
FRAGMENT_CLASSES = {
|
5
|
+
:year => "col-xs-4",
|
6
|
+
:month => "col-xs-5",
|
7
|
+
:day => "col-xs-3"
|
8
|
+
}
|
9
|
+
|
10
|
+
include Base
|
11
|
+
include Base::Timeish
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module FormtasticRebootstrap
|
2
|
+
module Inputs
|
3
|
+
class DatetimeInput < FormtasticRebootstrap::Inputs::DatetimeSelectInput
|
4
|
+
def to_html
|
5
|
+
::ActiveSupport::Deprecation.warn("DatetimeInput (:as => :datetime) has been renamed to DatetimeSelectInput (:as => :datetime_select) and will be removed or changed in the next version of Formtastic, please update your forms.", caller(2))
|
6
|
+
super
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|