dsfr-form_builder 0.0.9 → 0.0.10
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 +4 -4
- data/lib/dsfr-form_builder.rb +12 -15
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7a3b0281a3fcb20c950b387cbca97de25f41b57bbd54c52b530aa5c21231e45a
|
|
4
|
+
data.tar.gz: 9e85fc5734c0ad8bd58d362969ccc79b640e265e9d83c786fa72413a3c7d5fc8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 811d3caa1085841167dcc6b9b5ed6e66d2ee045d525d543f66e826c63c8e7a62ce8d0553c780418d5fa29097efed9ce390230a080ac588c1e91656717eb1535e
|
|
7
|
+
data.tar.gz: bcb368044c5956be29c034f5d1b92c6845414065d09068c88b4ba88ffa2b225d63ff9d585311d9bab6562ed2fa9eb887c0c31b690c37fa3e61bdee4538843a05
|
data/lib/dsfr-form_builder.rb
CHANGED
|
@@ -2,6 +2,8 @@ module Dsfr
|
|
|
2
2
|
include ActiveSupport::Configurable
|
|
3
3
|
|
|
4
4
|
class FormBuilder < ActionView::Helpers::FormBuilder
|
|
5
|
+
VERSION = "0.0.10"
|
|
6
|
+
|
|
5
7
|
include ActionView::Helpers::OutputSafetyHelper
|
|
6
8
|
|
|
7
9
|
attr_accessor :display_required_tags
|
|
@@ -36,7 +38,7 @@ module Dsfr
|
|
|
36
38
|
end
|
|
37
39
|
end
|
|
38
40
|
|
|
39
|
-
def dsfr_input_group(attribute,
|
|
41
|
+
def dsfr_input_group(attribute, kind: :input, **opts, &block)
|
|
40
42
|
@template.tag.div(
|
|
41
43
|
yield(block),
|
|
42
44
|
data: opts[:data],
|
|
@@ -49,7 +51,7 @@ module Dsfr
|
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
def dsfr_input_field(attribute, input_kind, opts = {})
|
|
52
|
-
dsfr_input_group(attribute, opts) do
|
|
54
|
+
dsfr_input_group(attribute, **opts) do
|
|
53
55
|
@template.safe_join([
|
|
54
56
|
dsfr_label_with_hint(attribute, opts),
|
|
55
57
|
public_send(input_kind, attribute, class: "fr-input", **opts.except(:class, :hint, :label, :data)),
|
|
@@ -59,7 +61,7 @@ module Dsfr
|
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
def dsfr_file_field(attribute, opts = {})
|
|
62
|
-
dsfr_input_group(attribute, opts, kind: :upload) do
|
|
64
|
+
dsfr_input_group(attribute, **opts, kind: :upload) do
|
|
63
65
|
@template.safe_join([
|
|
64
66
|
dsfr_label_with_hint(attribute, opts.except(:class)),
|
|
65
67
|
file_field(attribute, class: "fr-upload", **opts.except(:class, :hint, :label, :data)),
|
|
@@ -70,7 +72,7 @@ module Dsfr
|
|
|
70
72
|
|
|
71
73
|
def dsfr_check_box(attribute, opts = {}, checked_value = "1", unchecked_value = "0")
|
|
72
74
|
@template.tag.div(class: @template.class_names("fr-fieldset__element", "fr-fieldset__element--inline" => opts.delete(:inline))) do
|
|
73
|
-
dsfr_input_group(attribute, opts, kind: :checkbox) do
|
|
75
|
+
dsfr_input_group(attribute, **opts, kind: :checkbox) do
|
|
74
76
|
@template.safe_join([
|
|
75
77
|
check_box(attribute, opts.except(:label, :hint), checked_value, unchecked_value),
|
|
76
78
|
dsfr_label_with_hint(attribute, opts)
|
|
@@ -108,23 +110,18 @@ module Dsfr
|
|
|
108
110
|
end
|
|
109
111
|
end
|
|
110
112
|
|
|
111
|
-
def dsfr_select(attribute, choices, input_options
|
|
112
|
-
|
|
113
|
+
def dsfr_select(attribute, choices, input_options = {}, **html_options)
|
|
114
|
+
select_html_options = html_options.dup.except(:hint, :name)
|
|
115
|
+
select_html_options[:class] = @template.class_names("fr-select", select_html_options[:class])
|
|
116
|
+
dsfr_input_group(attribute, **html_options, kind: :select) do
|
|
113
117
|
@template.safe_join([
|
|
114
|
-
dsfr_label_with_hint(attribute,
|
|
115
|
-
|
|
118
|
+
dsfr_label_with_hint(attribute, html_options),
|
|
119
|
+
select(attribute, choices, input_options, **select_html_options),
|
|
116
120
|
dsfr_error_message(attribute)
|
|
117
121
|
])
|
|
118
122
|
end
|
|
119
123
|
end
|
|
120
124
|
|
|
121
|
-
def dsfr_select_tag(attribute, choices, opts)
|
|
122
|
-
opts[:class] = @template.class_names("fr-select", opts[:class])
|
|
123
|
-
options = opts.slice(:include_blank, :selected, :disabled)
|
|
124
|
-
html_options = opts.except(:include_blank, :selected, :disabled)
|
|
125
|
-
select(attribute, choices, options, **html_options)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
125
|
def dsfr_radio_buttons(attribute, choices, legend: nil, hint: nil, **opts)
|
|
129
126
|
legend_content = @template.safe_join([
|
|
130
127
|
legend || @object.class.human_attribute_name(attribute),
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dsfr-form_builder
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- BetaGouv developers
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-02-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionview
|