active_dry_form 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/active_dry_form/builder.rb +4 -6
- data/lib/active_dry_form/form_helper.rb +1 -3
- data/lib/active_dry_form/input.rb +8 -5
- data/lib/active_dry_form/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0134c8126c7ce5ea25422550c9ed232b668ce2d0e3b892bbc1535340bf2bcfe5
|
4
|
+
data.tar.gz: a1a90179815dec9d0964d6aa03612565afc1cafe157cb29eebeba225fcf0996d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb484a9edbfb4fe0f215717dbd4cab04b41ec6eaf33334c663ac588df393bdae26d13cd7d7c973d25e3c193a5f21871314142122679c91b44c3fee7765cd5af7
|
7
|
+
data.tar.gz: f845993ba3a0cc7c0756b610634cae6a1c6b3fb0e4cee3f45d985ffc045cbe10460637b198fdcbd35cdbc1f1ff71df105edddc55ac3aaaca18f832223a40b15e
|
data/Gemfile.lock
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
module ActiveDryForm
|
4
4
|
class Builder < ActionView::Helpers::FormBuilder
|
5
5
|
|
6
|
-
include ActionView::Helpers::TagHelper
|
7
|
-
include ActionView::Context
|
8
6
|
include Dry::Core::Constants
|
9
7
|
|
10
8
|
def input(field, options = {})
|
@@ -56,16 +54,16 @@ module ActiveDryForm
|
|
56
54
|
def show_base_errors
|
57
55
|
return if @object.base_errors.empty?
|
58
56
|
|
59
|
-
|
60
|
-
|
57
|
+
@template.content_tag(:div, class: ActiveDryForm.config.css_classes.base_error) do
|
58
|
+
@template.content_tag(:ul) do
|
61
59
|
# внутри ошибки может быть html
|
62
|
-
@object.base_errors.map {
|
60
|
+
@object.base_errors.map { @template.content_tag(:li, _1.html_safe) }.join.html_safe
|
63
61
|
end
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|
67
65
|
def show_error(field)
|
68
|
-
ActiveDryForm::Input.new(self,
|
66
|
+
ActiveDryForm::Input.new(self, nil, field, {}).error_text
|
69
67
|
end
|
70
68
|
|
71
69
|
def button(value = nil, options = {}, &block)
|
@@ -7,9 +7,7 @@ module ActiveDryForm
|
|
7
7
|
options[:builder] = ActiveDryForm::Builder
|
8
8
|
options[:html] = html_options(options)
|
9
9
|
|
10
|
-
|
11
|
-
# TODO: refactor to options[:url]
|
12
|
-
form_for(Array.wrap(name), options) do |f|
|
10
|
+
form_for(name, options) do |f|
|
13
11
|
concat f.show_base_errors
|
14
12
|
instance_exec(f, &block)
|
15
13
|
end
|
@@ -5,6 +5,9 @@ module ActiveDryForm
|
|
5
5
|
|
6
6
|
def initialize(builder, builder_method, field, options)
|
7
7
|
@builder = builder
|
8
|
+
@form_object = builder.object
|
9
|
+
@template = builder.instance_variable_get(:@template)
|
10
|
+
|
8
11
|
@builder_method = builder_method
|
9
12
|
@field = field
|
10
13
|
|
@@ -25,7 +28,7 @@ module ActiveDryForm
|
|
25
28
|
end
|
26
29
|
|
27
30
|
def wrap_tag(input, label_last: nil)
|
28
|
-
@
|
31
|
+
@template.tag(:div, class: css_classes) do
|
29
32
|
[
|
30
33
|
label_last ? input : label,
|
31
34
|
label_last ? label : input,
|
@@ -42,23 +45,23 @@ module ActiveDryForm
|
|
42
45
|
def hint_text
|
43
46
|
return unless @hint_text
|
44
47
|
|
45
|
-
@
|
48
|
+
@template.content_tag(:small, @hint_text, class: ActiveDryForm.config.css_classes.hint)
|
46
49
|
end
|
47
50
|
|
48
51
|
def error_text
|
49
52
|
return unless error?(@field)
|
50
53
|
|
51
54
|
obj_error_text =
|
52
|
-
case e = @
|
55
|
+
case e = @form_object.errors[@field]
|
53
56
|
when Hash then e.values
|
54
57
|
else e
|
55
58
|
end
|
56
59
|
|
57
|
-
@
|
60
|
+
@template.content_tag(:div, obj_error_text.join('<br />').html_safe, class: ActiveDryForm.config.css_classes.error)
|
58
61
|
end
|
59
62
|
|
60
63
|
def error?(field)
|
61
|
-
@
|
64
|
+
@form_object.errors.key?(field)
|
62
65
|
end
|
63
66
|
|
64
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_dry_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ermolaev Andrey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -112,6 +112,9 @@ homepage: https://github.com/corp-gp/active_dry_form
|
|
112
112
|
licenses:
|
113
113
|
- MIT
|
114
114
|
metadata:
|
115
|
+
allowed_push_host: https://rubygems.org
|
116
|
+
homepage_uri: https://github.com/corp-gp/active_dry_form
|
117
|
+
source_code_uri: https://github.com/corp-gp/active_dry_form
|
115
118
|
rubygems_mfa_required: 'true'
|
116
119
|
post_install_message:
|
117
120
|
rdoc_options: []
|