govuk_elements_form_builder 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 843a031b73d07acdc383b877b9f8e89633643973
|
4
|
+
data.tar.gz: 536f03612b0bf4a5ca317dd2077aa9ba9faca839
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abb4867e3a120e9e73a9e372fc257fe288d96e13a4818d6612be9a8753bbe676e92b74b52630abb0408374eb3d45a8e1e00d49a88905d6deb49500306fc53563
|
7
|
+
data.tar.gz: 522235932ca947ca2ef1d37220f09f1047010e4e2c9eaebb77cdc2cd4b3f00f57c432b0db06026510aaf72ed81067ca2e46c803421a545ebccf8b9d1bfd5598f
|
@@ -178,8 +178,9 @@ module GovukElementsErrorsHelper
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
|
+
# `underscore` changes '::' to '/' to convert namespaces to paths
|
181
182
|
def self.underscore_name object
|
182
|
-
object.class.name.underscore
|
183
|
+
object.class.name.underscore.tr('/'.freeze, '_'.freeze)
|
183
184
|
end
|
184
185
|
|
185
186
|
private_class_method :error_summary_div
|
@@ -28,11 +28,15 @@ module GovukElementsFormBuilder
|
|
28
28
|
define_method(method_name) do |attribute, *args|
|
29
29
|
content_tag :div, class: form_group_classes(attribute), id: form_group_id(attribute) do
|
30
30
|
options = args.extract_options!
|
31
|
+
|
32
|
+
set_label_classes! options
|
31
33
|
set_field_classes! options
|
32
34
|
|
33
|
-
label = label(attribute,
|
35
|
+
label = label(attribute, options[:label_options])
|
36
|
+
|
34
37
|
add_hint :label, label, attribute
|
35
|
-
|
38
|
+
|
39
|
+
(label + super(attribute, options.except(:label, :label_options))).html_safe
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
@@ -92,6 +96,26 @@ module GovukElementsFormBuilder
|
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
99
|
+
def set_label_classes! options
|
100
|
+
text_field_class = "form-label"
|
101
|
+
|
102
|
+
if options.present? && options[:label_options].present?
|
103
|
+
options[:label_options][:class] = case options[:label_options][:class]
|
104
|
+
when String
|
105
|
+
[text_field_class, options[:label_options][:class]]
|
106
|
+
when Array
|
107
|
+
options[:label_options][:class].unshift text_field_class
|
108
|
+
else
|
109
|
+
options[:label_options][:class] = text_field_class
|
110
|
+
end
|
111
|
+
else
|
112
|
+
options ||= {}
|
113
|
+
options[:label_options] ||= {}
|
114
|
+
options[:label_options][:class] = text_field_class
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
95
119
|
def check_box_inputs attributes
|
96
120
|
attributes.map do |attribute|
|
97
121
|
label(attribute, class: 'block-label selection-button-checkbox') do |tag|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_elements_form_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alistair Laing
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|