phlexi-form 0.4.0 → 0.4.2
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e48bcf63b4a10f2a96634c9bc29da6d4aaf2aa2b07610a068b8855f3b886f00
|
4
|
+
data.tar.gz: 9dc72e580de4b3c2106b8b11b87ee9c98f529541d7fb32338fd6a0364fe7ad8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: badb2048ae77cffec7f21d75f010fe60cf66fce6da0131d2432d4f1a530f48a7ef9694e46386106e87d165456dd641fe096d9eb3f6c24db0bdf4426b69d720a8
|
7
|
+
data.tar.gz: 124992bdef2e96b91a238ba124be3a587252cf113df6bc75fe88b94b18090cda1b075ac6e24c835be11b4debfd0788a78dc5f054487ec7453987cf8188c05536
|
data/lib/phlexi/form/base.rb
CHANGED
@@ -22,6 +22,8 @@ module Phlexi
|
|
22
22
|
|
23
23
|
class Builder < Phlexi::Form::Builder; end
|
24
24
|
|
25
|
+
class Errors < Phlexi::Form::Components::FormErrors; end
|
26
|
+
|
25
27
|
def self.inline(*, **, &block)
|
26
28
|
raise ArgumentError, "block is required" unless block
|
27
29
|
|
@@ -61,7 +63,28 @@ module Phlexi
|
|
61
63
|
#
|
62
64
|
# @return [void]
|
63
65
|
def view_template(&)
|
64
|
-
form_tag {
|
66
|
+
form_tag {
|
67
|
+
form_errors
|
68
|
+
form_template(&)
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
def form_errors
|
73
|
+
return unless errors.present?
|
74
|
+
|
75
|
+
render self.class::Errors.new error_message, errors
|
76
|
+
end
|
77
|
+
|
78
|
+
def error_message
|
79
|
+
lookups = []
|
80
|
+
lookups << :"#{key}"
|
81
|
+
lookups << :default_message
|
82
|
+
lookups << options.fetch(:error_message) { "Please review the problems below" }
|
83
|
+
I18n.t(lookups.shift, scope: :"phlexi_form.error_notification", default: lookups)
|
84
|
+
end
|
85
|
+
|
86
|
+
def errors
|
87
|
+
@errors ||= options.fetch(:errors) { object.respond_to?(:errors) && object.errors.full_messages }
|
65
88
|
end
|
66
89
|
|
67
90
|
# Executes the form's content block.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phlexi
|
4
|
+
module Form
|
5
|
+
module Components
|
6
|
+
class FormErrors < Phlexi::Form::HTML
|
7
|
+
def initialize(message, errors)
|
8
|
+
@message = message
|
9
|
+
@errors = errors
|
10
|
+
end
|
11
|
+
|
12
|
+
def view_template
|
13
|
+
div(class: themed(:form_errors_wrapper, nil), role: "alert") do
|
14
|
+
div(class: themed(:form_errors_inner_wrapper, nil)) do
|
15
|
+
p(class: themed(:form_errors_message, nil)) { @message }
|
16
|
+
ul(class: themed(:form_errors_list, nil)) do
|
17
|
+
@errors.each do |error|
|
18
|
+
li(class: themed(:form_errors_list_item, nil)) {
|
19
|
+
error.to_s
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -4,7 +4,7 @@ module Phlexi
|
|
4
4
|
module Form
|
5
5
|
module Structure
|
6
6
|
class FieldCollection < Phlexi::Field::Structure::FieldCollection
|
7
|
-
class Builder < Builder
|
7
|
+
class Builder < Phlexi::Field::Structure::FieldCollection::Builder
|
8
8
|
def field(**options)
|
9
9
|
options = mix({input_attributes: @field.input_attributes}, options)
|
10
10
|
@field.class.new(key, **options, parent: @field).tap do |field|
|
data/lib/phlexi/form/theme.rb
CHANGED
data/lib/phlexi/form/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phlexi-form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Froelich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phlex
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/phlexi/form/components/concerns/submits_form.rb
|
217
217
|
- lib/phlexi/form/components/error.rb
|
218
218
|
- lib/phlexi/form/components/file_input.rb
|
219
|
+
- lib/phlexi/form/components/form_errors.rb
|
219
220
|
- lib/phlexi/form/components/full_error.rb
|
220
221
|
- lib/phlexi/form/components/hint.rb
|
221
222
|
- lib/phlexi/form/components/input.rb
|