speedo-formstrap 1.2.0 → 1.2.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.
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/formtastic-bootstrap.gemspec +1 -1
- data/lib/formtastic-bootstrap.rb +5 -5
- data/lib/formtastic-bootstrap/actions.rb +4 -4
- data/lib/formtastic-bootstrap/actions/base.rb +1 -1
- data/lib/formtastic-bootstrap/actions/button_action.rb +1 -1
- data/lib/formtastic-bootstrap/actions/input_action.rb +1 -1
- data/lib/formtastic-bootstrap/actions/link_action.rb +1 -1
- data/lib/formtastic-bootstrap/engine.rb +1 -1
- data/lib/formtastic-bootstrap/form_builder.rb +9 -11
- data/lib/formtastic-bootstrap/helpers.rb +6 -8
- data/lib/formtastic-bootstrap/helpers/action_helper.rb +2 -2
- data/lib/formtastic-bootstrap/helpers/actions_helper.rb +2 -2
- data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +10 -14
- data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +7 -12
- data/lib/formtastic-bootstrap/helpers/input_helper.rb +2 -2
- data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +6 -6
- data/lib/formtastic-bootstrap/inputs.rb +21 -21
- data/lib/formtastic-bootstrap/inputs/base.rb +10 -11
- data/lib/formtastic-bootstrap/inputs/base/choices.rb +24 -13
- data/lib/formtastic-bootstrap/inputs/base/errors.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/hints.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/html.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/labelling.rb +7 -17
- data/lib/formtastic-bootstrap/inputs/base/numeric.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/stringish.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/timeish.rb +13 -6
- data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +15 -33
- data/lib/formtastic-bootstrap/inputs/boolean_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/date_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/datetime_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/email_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/file_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/hidden_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/number_input.rb +3 -3
- data/lib/formtastic-bootstrap/inputs/password_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/phone_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/radio_input.rb +13 -14
- data/lib/formtastic-bootstrap/inputs/range_input.rb +3 -3
- data/lib/formtastic-bootstrap/inputs/search_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/select_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/string_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/text_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/time_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/url_input.rb +1 -1
- data/spec/actions/button_action_spec.rb +1 -1
- data/spec/actions/generic_action_spec.rb +1 -1
- data/spec/actions/input_action_spec.rb +1 -1
- data/spec/actions/link_action_spec.rb +1 -1
- data/spec/builder/semantic_fields_for_spec.rb +16 -16
- data/spec/helpers/action_helper_spec.rb +1 -1
- data/spec/helpers/actions_helper_spec.rb +1 -1
- data/spec/helpers/buttons_helper_spec.rb +46 -56
- data/spec/helpers/input_helper_spec.rb +209 -209
- data/spec/helpers/inputs_helper_spec.rb +103 -117
- data/spec/inputs/boolean_input_spec.rb +46 -74
- data/spec/inputs/check_boxes_input_spec.rb +82 -110
- data/spec/inputs/date_input_spec.rb +15 -81
- data/spec/inputs/datetime_input_spec.rb +13 -13
- data/spec/inputs/email_input_spec.rb +6 -34
- data/spec/inputs/file_input_spec.rb +6 -34
- data/spec/inputs/hidden_input_spec.rb +13 -41
- data/spec/inputs/number_input_spec.rb +97 -127
- data/spec/inputs/password_input_spec.rb +6 -34
- data/spec/inputs/phone_input_spec.rb +6 -34
- data/spec/inputs/radio_input_spec.rb +45 -73
- data/spec/inputs/range_input_spec.rb +66 -94
- data/spec/inputs/search_input_spec.rb +6 -33
- data/spec/inputs/select_input_spec.rb +78 -124
- data/spec/inputs/string_input_spec.rb +22 -67
- data/spec/inputs/text_input_spec.rb +15 -42
- data/spec/inputs/time_input_spec.rb +23 -23
- data/spec/inputs/time_zone_input_spec.rb +20 -20
- data/spec/inputs/url_input_spec.rb +6 -34
- data/spec/support/custom_macros.rb +196 -67
- data/spec/support/formtastic_spec_helper.rb +6 -22
- data/speedo-formstrap.gemspec +146 -0
- metadata +18 -17
data/README.md
CHANGED
@@ -27,7 +27,7 @@ And install it with <tt>bundle install</tt>.
|
|
27
27
|
Add the following line to your Formtastic initialization file:
|
28
28
|
|
29
29
|
# config/initializers/formtastic.rb
|
30
|
-
Formtastic::Helpers::FormHelper.builder =
|
30
|
+
Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
|
31
31
|
|
32
32
|
Make sure the CSS `.hidden {display:none;}` is in your project.
|
33
33
|
|
@@ -141,7 +141,7 @@ To create a Prepended Text field, use the ```:prepend``` option. This works on
|
|
141
141
|
|
142
142
|
### Contributors
|
143
143
|
|
144
|
-
A big thank you [to all contributors](https://github.com/mjbellantoni/
|
144
|
+
A big thank you [to all contributors](https://github.com/mjbellantoni/speedo-formstrap/contributors)!
|
145
145
|
|
146
146
|
### Submitting Issues
|
147
147
|
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ require 'jeweler'
|
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
17
|
gem.name = "speedo-formstrap"
|
18
|
-
gem.homepage = "http://github.com/thugsb/
|
18
|
+
gem.homepage = "http://github.com/thugsb/speedo-formstrap"
|
19
19
|
gem.license = "MIT"
|
20
20
|
gem.summary = %Q{Formtastic form builder to generate Twitter Bootstrap-friendly markup.}
|
21
21
|
gem.description = gem.summary
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
"README.md"
|
18
18
|
]
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
|
-
s.homepage = "http://github.com/thugsb/
|
20
|
+
s.homepage = "http://github.com/thugsb/speedo-formstrap"
|
21
21
|
s.licenses = ["MIT"]
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
s.rubygems_version = "1.8.10"
|
data/lib/formtastic-bootstrap.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "formtastic"
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
require "
|
2
|
+
require "speedo-formstrap/engine" if defined?(::Rails) # For tests
|
3
|
+
require "speedo-formstrap/helpers"
|
4
|
+
require "speedo-formstrap/inputs"
|
5
|
+
require "speedo-formstrap/actions"
|
6
|
+
require "speedo-formstrap/form_builder"
|
7
7
|
require "action_view/helpers/text_field_date_helper"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
require "
|
1
|
+
require "speedo-formstrap/actions/base"
|
2
|
+
require "speedo-formstrap/actions/input_action"
|
3
|
+
require "speedo-formstrap/actions/link_action"
|
4
|
+
require "speedo-formstrap/actions/button_action"
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module
|
2
|
-
|
1
|
+
module SpeedoFormstrap
|
2
|
+
|
3
3
|
class FormBuilder < Formtastic::FormBuilder
|
4
4
|
|
5
5
|
configure :default_inline_error_class, 'help-inline'
|
@@ -11,30 +11,28 @@ module FormtasticBootstrap
|
|
11
11
|
# self.default_inline_error_class
|
12
12
|
raise
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def self.default_error_class=(error_class)
|
16
16
|
# self.default_inline_error_class = error_class
|
17
17
|
# self.default_block_error_class = error_class
|
18
18
|
raise
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def self.default_hint_class
|
22
22
|
# self.default_inline_hint_class
|
23
23
|
raise
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def self.default_hint_class=(hint_class)
|
27
27
|
# self.default_inline_hint_class = hint_class
|
28
28
|
# self.default_block_hint_class = hint_class
|
29
29
|
raise
|
30
30
|
end
|
31
31
|
|
32
|
-
include
|
33
|
-
include
|
34
|
-
include
|
35
|
-
include FormtasticBootstrap::Helpers::ActionHelper
|
36
|
-
include FormtasticBootstrap::Helpers::ActionsHelper
|
32
|
+
include SpeedoFormstrap::Helpers::InputHelper
|
33
|
+
include SpeedoFormstrap::Helpers::InputsHelper
|
34
|
+
include SpeedoFormstrap::Helpers::ButtonsHelper
|
37
35
|
|
38
36
|
end
|
39
37
|
|
40
|
-
end
|
38
|
+
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "formtastic-bootstrap/helpers/input_helper"
|
6
|
-
require "formtastic-bootstrap/helpers/inputs_helper"
|
1
|
+
require "speedo-formstrap/helpers/buttons_helper"
|
2
|
+
require "speedo-formstrap/helpers/fieldset_wrapper"
|
3
|
+
require "speedo-formstrap/helpers/input_helper"
|
4
|
+
require "speedo-formstrap/helpers/inputs_helper"
|
7
5
|
|
8
|
-
module
|
6
|
+
module SpeedoFormstrap
|
9
7
|
module Helpers
|
10
8
|
# autoload :ErrorsHelper, 'formtastic/helpers/errors_helper'
|
11
9
|
# autoload :FieldsetWrapper, 'formtastic/helpers/fieldset_wrapper'
|
@@ -13,7 +11,7 @@ module FormtasticBootstrap
|
|
13
11
|
# autoload :FormHelper, 'formtastic/helpers/form_helper'
|
14
12
|
# autoload :InputHelper, 'formtastic/helpers/input_helper'
|
15
13
|
# autoload :InputsHelper, 'formtastic/helpers/inputs_helper'
|
16
|
-
# autoload :LabelHelper, 'formtastic/helpers/label_helper'
|
14
|
+
# autoload :LabelHelper, 'formtastic/helpers/label_helper'
|
17
15
|
# autoload :SemanticFormHelper, 'formtastic/helpers/semantic_form_helper'
|
18
16
|
# autoload :Reflection, 'formtastic/helpers/reflection'
|
19
17
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Helpers
|
3
3
|
module ActionHelper
|
4
4
|
include Formtastic::Helpers::ActionHelper
|
5
5
|
|
6
6
|
def standard_action_class_name(as)
|
7
|
-
"
|
7
|
+
"SpeedoFormstrap::Actions::#{as.to_s.camelize}Action"
|
8
8
|
end
|
9
9
|
|
10
10
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Helpers
|
3
3
|
module ActionsHelper
|
4
4
|
|
5
5
|
include Formtastic::Helpers::ActionsHelper
|
6
|
-
include
|
6
|
+
include SpeedoFormstrap::Helpers::FieldsetWrapper
|
7
7
|
|
8
8
|
def actions(*args, &block)
|
9
9
|
html_options = args.extract_options!
|
@@ -1,15 +1,14 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Helpers
|
3
3
|
module ButtonsHelper
|
4
4
|
|
5
5
|
include Formtastic::Helpers::ButtonsHelper
|
6
6
|
|
7
7
|
def buttons(*args, &block)
|
8
|
-
::ActiveSupport::Deprecation.warn("f.buttons is deprecated in favour of f.actions and will be removed from Formtastic after 2.1. Please see ActionsHelper and InputAction or ButtonAction for more information")
|
9
8
|
|
10
9
|
html_options = args.extract_options!
|
11
|
-
html_options[:class] ||= "
|
12
|
-
|
10
|
+
html_options[:class] ||= "actions"
|
11
|
+
|
13
12
|
if html_options.has_key?(:name)
|
14
13
|
ActiveSupport::Deprecation.warn('The :name option is not supported')
|
15
14
|
end
|
@@ -17,7 +16,7 @@ module FormtasticBootstrap
|
|
17
16
|
if block_given?
|
18
17
|
template.content_tag(:div, html_options) do
|
19
18
|
yield
|
20
|
-
end
|
19
|
+
end
|
21
20
|
else
|
22
21
|
args = [:commit] if args.empty?
|
23
22
|
contents = args.map { |button_name| send(:"#{button_name}_button") }
|
@@ -29,28 +28,25 @@ module FormtasticBootstrap
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def commit_button(*args)
|
32
|
-
::ActiveSupport::Deprecation.warn("f.commit_button is deprecated in favour of f.action(:submit) and will be removed from Formtastic after 2.1. Please see ActionsHelper and InputAction or ButtonAction for more information")
|
33
|
-
|
34
31
|
options = args.extract_options!
|
35
32
|
text = options.delete(:label) || args.shift
|
36
|
-
|
33
|
+
|
37
34
|
text = (localized_string(commit_button_i18n_key, text, :action, :model => commit_button_object_name) ||
|
38
35
|
Formtastic::I18n.t(commit_button_i18n_key, :model => commit_button_object_name)) unless text.is_a?(::String)
|
39
|
-
|
36
|
+
|
40
37
|
button_html = options.delete(:button_html) || {}
|
41
|
-
button_html[:id] ||= "#{@object_name}_submit"
|
42
38
|
button_html.merge!(:class => [button_html[:class], "btn commit", commit_button_i18n_key].compact.join(' '))
|
43
|
-
|
39
|
+
|
44
40
|
# TODO We don't have a wrapper. Add deprecation message.
|
45
41
|
# wrapper_html = options.delete(:wrapper_html) || {}
|
46
42
|
# wrapper_html[:class] = (commit_button_wrapper_html_class << wrapper_html[:class]).flatten.compact.join(' ')
|
47
|
-
|
43
|
+
|
48
44
|
accesskey = (options.delete(:accesskey) || default_commit_button_accesskey) unless button_html.has_key?(:accesskey)
|
49
45
|
button_html = button_html.merge(:accesskey => accesskey) if accesskey
|
50
|
-
|
46
|
+
|
51
47
|
Formtastic::Util.html_safe(submit(text, button_html))
|
52
48
|
end
|
53
49
|
|
54
50
|
end
|
55
51
|
end
|
56
|
-
end
|
52
|
+
end
|
@@ -1,15 +1,19 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Helpers
|
3
3
|
module FieldsetWrapper
|
4
4
|
|
5
5
|
include Formtastic::Helpers::FieldsetWrapper
|
6
|
-
|
6
|
+
|
7
7
|
protected
|
8
8
|
|
9
9
|
def field_set_and_list_wrapping(*args, &block) #:nodoc:
|
10
10
|
contents = args.last.is_a?(::Hash) ? '' : args.pop.flatten
|
11
11
|
html_options = args.extract_options!
|
12
12
|
|
13
|
+
legend = (html_options[:name] || '').to_s
|
14
|
+
legend %= parent_child_index(html_options[:parent]) if html_options[:parent]
|
15
|
+
legend = template.content_tag(:legend, Formtastic::Util.html_safe(legend)) unless legend.blank?
|
16
|
+
|
13
17
|
if block_given?
|
14
18
|
contents = if template.respond_to?(:is_haml?) && template.is_haml?
|
15
19
|
template.capture_haml(&block)
|
@@ -20,8 +24,6 @@ module FormtasticBootstrap
|
|
20
24
|
|
21
25
|
# Ruby 1.9: String#to_s behavior changed, need to make an explicit join.
|
22
26
|
contents = contents.join if contents.respond_to?(:join)
|
23
|
-
|
24
|
-
legend = field_set_legend(html_options)
|
25
27
|
fieldset = template.content_tag(:fieldset,
|
26
28
|
Formtastic::Util.html_safe(legend) << Formtastic::Util.html_safe(contents),
|
27
29
|
html_options.except(:builder, :parent, :name)
|
@@ -30,13 +32,6 @@ module FormtasticBootstrap
|
|
30
32
|
fieldset
|
31
33
|
end
|
32
34
|
|
33
|
-
def field_set_legend(html_options)
|
34
|
-
legend = (html_options[:name] || '').to_s
|
35
|
-
legend %= parent_child_index(html_options[:parent]) if html_options[:parent]
|
36
|
-
legend = template.content_tag(:legend, Formtastic::Util.html_safe(legend)) unless legend.blank?
|
37
|
-
legend
|
38
|
-
end
|
39
|
-
|
40
35
|
end
|
41
36
|
end
|
42
|
-
end
|
37
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Helpers
|
3
3
|
module InputHelper
|
4
4
|
include Formtastic::Helpers::InputHelper
|
5
5
|
|
6
6
|
def standard_input_class_name(as)
|
7
|
-
"
|
7
|
+
"SpeedoFormstrap::Inputs::#{as.to_s.camelize}Input"
|
8
8
|
end
|
9
9
|
|
10
10
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Helpers
|
3
3
|
module InputsHelper
|
4
|
-
include
|
4
|
+
include SpeedoFormstrap::Helpers::FieldsetWrapper
|
5
5
|
|
6
6
|
def inputs(*args, &block)
|
7
7
|
wrap_it = @already_in_an_inputs_block ? true : false
|
8
8
|
@already_in_an_inputs_block = true
|
9
|
-
|
9
|
+
|
10
10
|
title = field_set_title_from_args(*args)
|
11
11
|
html_options = args.extract_options!
|
12
12
|
html_options[:class] ||= "inputs"
|
@@ -25,12 +25,12 @@ module FormtasticBootstrap
|
|
25
25
|
field_set_and_list_wrapping(*((args << html_options) << contents))
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
# out = template.content_tag(:li, out, :class => "input") if wrap_it
|
30
|
-
@already_in_an_inputs_block =
|
30
|
+
@already_in_an_inputs_block = false
|
31
31
|
out
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
35
35
|
end
|
36
|
-
end
|
36
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
require "
|
9
|
-
require "
|
10
|
-
require "
|
11
|
-
require "
|
12
|
-
require "
|
13
|
-
require "
|
14
|
-
require "
|
15
|
-
require "
|
16
|
-
require "
|
17
|
-
require "
|
18
|
-
require "
|
19
|
-
require "
|
20
|
-
require "
|
1
|
+
require "speedo-formstrap/inputs/base"
|
2
|
+
require "speedo-formstrap/inputs/boolean_input"
|
3
|
+
require "speedo-formstrap/inputs/check_boxes_input"
|
4
|
+
require "speedo-formstrap/inputs/date_input"
|
5
|
+
require "speedo-formstrap/inputs/datetime_input"
|
6
|
+
require "speedo-formstrap/inputs/email_input"
|
7
|
+
require "speedo-formstrap/inputs/file_input"
|
8
|
+
require "speedo-formstrap/inputs/hidden_input"
|
9
|
+
require "speedo-formstrap/inputs/number_input"
|
10
|
+
require "speedo-formstrap/inputs/password_input"
|
11
|
+
require "speedo-formstrap/inputs/phone_input"
|
12
|
+
require "speedo-formstrap/inputs/radio_input"
|
13
|
+
require "speedo-formstrap/inputs/range_input"
|
14
|
+
require "speedo-formstrap/inputs/search_input"
|
15
|
+
require "speedo-formstrap/inputs/select_input"
|
16
|
+
require "speedo-formstrap/inputs/string_input"
|
17
|
+
require "speedo-formstrap/inputs/text_input"
|
18
|
+
require "speedo-formstrap/inputs/time_input"
|
19
|
+
require "speedo-formstrap/inputs/time_zone_input"
|
20
|
+
require "speedo-formstrap/inputs/url_input"
|
21
21
|
|
22
|
-
module
|
22
|
+
module SpeedoFormstrap
|
23
23
|
module Inputs
|
24
24
|
|
25
25
|
include Base
|
@@ -1,14 +1,13 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
require "
|
9
|
-
require "formtastic-bootstrap/inputs/base/wrapping"
|
1
|
+
require "speedo-formstrap/inputs/base/choices"
|
2
|
+
require "speedo-formstrap/inputs/base/errors"
|
3
|
+
require "speedo-formstrap/inputs/base/hints"
|
4
|
+
require "speedo-formstrap/inputs/base/html"
|
5
|
+
require "speedo-formstrap/inputs/base/labelling"
|
6
|
+
require "speedo-formstrap/inputs/base/stringish"
|
7
|
+
require "speedo-formstrap/inputs/base/timeish"
|
8
|
+
require "speedo-formstrap/inputs/base/wrapping"
|
10
9
|
|
11
|
-
module
|
10
|
+
module SpeedoFormstrap
|
12
11
|
module Inputs
|
13
12
|
module Base
|
14
13
|
|
@@ -17,7 +16,7 @@ module FormtasticBootstrap
|
|
17
16
|
include Html
|
18
17
|
include Labelling
|
19
18
|
include Wrapping
|
20
|
-
|
19
|
+
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
@@ -1,38 +1,49 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Inputs
|
3
3
|
module Base
|
4
4
|
module Choices
|
5
5
|
|
6
6
|
def input_div_wrapping(&block)
|
7
7
|
template.content_tag(:div, choices_wrapping_html_options) do
|
8
|
-
[yield, error_html(:block), hint_html(:block)].join("\n").html_safe
|
8
|
+
[yield, error_html(:block), hint_html(:block)].join("\n").html_safe
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def choices_wrapping_html_options
|
13
|
-
|
14
|
-
|
13
|
+
# TODO Call the Formtastic one explicity and append?
|
14
|
+
{ :class => "choices input" }
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
def choices_group_wrapping(&block)
|
18
|
+
template.content_tag(:ul,
|
19
|
+
template.capture(&block),
|
20
|
+
choices_group_wrapping_html_options
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def choices_group_wrapping_html_options
|
25
|
+
{ :class => "choices-group inputs-list" }
|
26
|
+
end
|
27
|
+
|
28
|
+
def choice_label(choice)
|
29
|
+
"\n".html_safe + template.content_tag(:span) do
|
30
|
+
# (choice.is_a?(Array) ? choice.first : choice).to_s
|
31
|
+
(choice.is_a?(Array) ? choice.first : choice).to_s
|
32
|
+
end
|
33
|
+
end
|
23
34
|
|
24
35
|
# This is actually a label in Bootstrap.
|
25
36
|
def legend_html
|
26
|
-
template.content_tag(:label,
|
37
|
+
template.content_tag(:label, label_html_options) do
|
27
38
|
render_label? ? label_text : "".html_safe
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
31
|
-
def
|
42
|
+
def label_html_options
|
32
43
|
super.merge(:for => nil)
|
33
44
|
end
|
34
45
|
|
35
46
|
end
|
36
47
|
end
|
37
48
|
end
|
38
|
-
end
|
49
|
+
end
|