dynamic_form 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/dynamic_form.gemspec +2 -3
- data/init.rb +1 -1
- data/lib/action_view/helpers/dynamic_form.rb +4 -4
- data/lib/action_view/locale/en.yml +8 -7
- data/lib/active_model/dynamic_errors.rb +14 -19
- data/test/dynamic_form_i18n_test.rb +6 -6
- metadata +44 -61
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b0a342fb584e366ee3435e4d9e017602b9a68e5eb5a55e68f98289cc2de10e72
|
4
|
+
data.tar.gz: bfd5abc37fe514962445b6b2d7678296d9befab2dd130e2fc79572dfea773b7f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7bdc76650d236b6f8074e4d92284c76f5b15a095ff2aff008ffb2ac620b707580ba5f3d1fdda75a7a45503cdfdd25d73e5871975165ba0c8e89acf090f51761a
|
7
|
+
data.tar.gz: 5e4935361a88e1e0290d681efe89206684101cc86788e431cdde2bb7ce4cea308a3120b43f107a8d907706a28f7b8a02f825a0b4ea19fcca228831d4907f3dec
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ DynamicForm holds a few helpers method to help you deal with your Rails3 models,
|
|
8
8
|
* `error_message_on(object, method, options={})`
|
9
9
|
* `error_messages_for(record, options={})`
|
10
10
|
|
11
|
-
It also adds `f.error_messages` and `f.
|
11
|
+
It also adds `f.error_messages` and `f.error_message_on` to your form builders.
|
12
12
|
|
13
13
|
Read `/lib/action_view/helpers/dynamic_form.rb` for details of each method.
|
14
14
|
|
@@ -50,7 +50,7 @@ DynamicForm can be installed as a gem in your `Gemfile`:
|
|
50
50
|
|
51
51
|
or as a plugin by running this command:
|
52
52
|
|
53
|
-
rails plugin install git://
|
53
|
+
rails plugin install git://github.com/joelmoss/dynamic_form.git
|
54
54
|
|
55
55
|
---
|
56
56
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.4
|
data/dynamic_form.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dynamic_form}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joel Moss"]
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
"test/dynamic_form_test.rb",
|
35
35
|
"test/test_helper.rb"
|
36
36
|
]
|
37
|
-
s.homepage = %q{http://
|
37
|
+
s.homepage = %q{http://github.com/joelmoss/dynamic_form}
|
38
38
|
s.rdoc_options = ["--charset=UTF-8"]
|
39
39
|
s.require_paths = ["lib"]
|
40
40
|
s.rubygems_version = %q{1.3.7}
|
@@ -58,4 +58,3 @@ Gem::Specification.new do |s|
|
|
58
58
|
s.add_dependency(%q<mocha>, [">= 0"])
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
data/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'dynamic_form'
|
1
|
+
require 'dynamic_form'
|
@@ -212,7 +212,7 @@ module ActionView
|
|
212
212
|
end
|
213
213
|
options[:object_name] ||= params.first
|
214
214
|
|
215
|
-
I18n.with_options :locale => options[:locale], :scope => [:errors, :template] do |locale|
|
215
|
+
I18n.with_options :locale => options[:locale], :scope => [:activerecord, :errors, :template] do |locale|
|
216
216
|
header_message = if options.include?(:header_message)
|
217
217
|
options[:header_message]
|
218
218
|
else
|
@@ -221,11 +221,11 @@ module ActionView
|
|
221
221
|
|
222
222
|
message = options.include?(:message) ? options[:message] : locale.t(:body)
|
223
223
|
|
224
|
-
error_messages = objects.
|
224
|
+
error_messages = objects.map do |object|
|
225
225
|
object.errors.full_messages.map do |msg|
|
226
226
|
content_tag(:li, msg)
|
227
227
|
end
|
228
|
-
end.join.html_safe
|
228
|
+
end.inject(:+).join.html_safe
|
229
229
|
|
230
230
|
contents = ''
|
231
231
|
contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank?
|
@@ -267,7 +267,7 @@ module ActionView
|
|
267
267
|
when :time
|
268
268
|
to_time_select_tag(options)
|
269
269
|
when :boolean
|
270
|
-
to_boolean_select_tag(options)
|
270
|
+
to_boolean_select_tag(options).html_safe
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
en:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
activerecord:
|
3
|
+
errors:
|
4
|
+
template:
|
5
|
+
header:
|
6
|
+
one: "1 error prohibited this %{model} from being saved"
|
7
|
+
other: "%{count} errors prohibited this %{model} from being saved"
|
8
|
+
# The variable :count is also available
|
9
|
+
body: "There were problems with the following fields:"
|
@@ -13,27 +13,22 @@ module ActiveModel
|
|
13
13
|
def full_messages
|
14
14
|
full_messages = []
|
15
15
|
|
16
|
-
each do |
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
if attribute == :base
|
21
|
-
messages.each {|m| full_messages << m }
|
16
|
+
each do |error|
|
17
|
+
if error.attribute == :base
|
18
|
+
full_messages << error.message
|
22
19
|
else
|
23
|
-
attr_name = attribute.to_s.gsub('.', '_').humanize
|
24
|
-
attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)
|
20
|
+
attr_name = error.attribute.to_s.gsub('.', '_').humanize
|
21
|
+
attr_name = @base.class.human_attribute_name(error.attribute, :default => attr_name)
|
25
22
|
options = { :default => "%{attribute} %{message}", :attribute => attr_name }
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
full_messages << I18n.t(:"errors.format", options.merge(:message => m))
|
36
|
-
end
|
24
|
+
if error.message =~ /^\^/
|
25
|
+
options[:default] = "%{message}"
|
26
|
+
full_messages << I18n.t(:"errors.dynamic_format", **options.merge(:message => error.message[1..-1]))
|
27
|
+
elsif error.message.is_a? Proc
|
28
|
+
options[:default] = "%{message}"
|
29
|
+
full_messages << I18n.t(:"errors.dynamic_format", **options.merge(:message => error.message.call(@base)))
|
30
|
+
else
|
31
|
+
full_messages << I18n.t(:"errors.format", **options.merge(:message => error.message))
|
37
32
|
end
|
38
33
|
end
|
39
34
|
end
|
@@ -44,4 +39,4 @@ module ActiveModel
|
|
44
39
|
end
|
45
40
|
|
46
41
|
require 'active_support/i18n'
|
47
|
-
I18n.load_path << File.dirname(__FILE__) + '/locale/en.yml'
|
42
|
+
I18n.load_path << File.dirname(__FILE__) + '/locale/en.yml'
|
@@ -16,27 +16,27 @@ class DynamicFormI18nTest < Test::Unit::TestCase
|
|
16
16
|
|
17
17
|
stubs(:content_tag).returns 'content_tag'
|
18
18
|
|
19
|
-
I18n.stubs(:t).with(:'header', :locale => 'en', :scope => [:errors, :template], :count => 1, :model => '').returns "1 error prohibited this from being saved"
|
20
|
-
I18n.stubs(:t).with(:'body', :locale => 'en', :scope => [:errors, :template]).returns 'There were problems with the following fields:'
|
19
|
+
I18n.stubs(:t).with(:'header', :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => '').returns "1 error prohibited this from being saved"
|
20
|
+
I18n.stubs(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).returns 'There were problems with the following fields:'
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_error_messages_for_given_a_header_option_it_does_not_translate_header_message
|
24
|
-
I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:errors, :template], :count => 1, :model => '').never
|
24
|
+
I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => '').never
|
25
25
|
error_messages_for(:object => @object, :header_message => 'header message', :locale => 'en')
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_error_messages_for_given_no_header_option_it_translates_header_message
|
29
|
-
I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:errors, :template], :count => 1, :model => '').returns 'header message'
|
29
|
+
I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => '').returns 'header message'
|
30
30
|
error_messages_for(:object => @object, :locale => 'en')
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_error_messages_for_given_a_message_option_it_does_not_translate_message
|
34
|
-
I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:errors, :template]).never
|
34
|
+
I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).never
|
35
35
|
error_messages_for(:object => @object, :message => 'message', :locale => 'en')
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_error_messages_for_given_no_message_option_it_translates_message
|
39
|
-
I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:errors, :template]).returns 'There were problems with the following fields:'
|
39
|
+
I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).returns 'There were problems with the following fields:'
|
40
40
|
error_messages_for(:object => @object, :locale => 'en')
|
41
41
|
end
|
42
42
|
end
|
metadata
CHANGED
@@ -1,47 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_form
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 3
|
10
|
-
version: 1.1.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Joel Moss
|
14
|
-
autorequire:
|
8
|
+
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2010-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: mocha
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
27
17
|
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
33
20
|
type: :development
|
34
|
-
|
35
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: DynamicForm holds a few helper methods to help you deal with your Rails3
|
28
|
+
models. It includes the stripped out methods from Rails 2; error_message_on and
|
29
|
+
error_messages_for. It also brings in the functionality of the custom-err-messages
|
30
|
+
plugin, which provides more flexibility over your model error messages.
|
36
31
|
email: joel@developwithstyle.com
|
37
32
|
executables: []
|
38
|
-
|
39
33
|
extensions: []
|
40
|
-
|
41
|
-
extra_rdoc_files:
|
34
|
+
extra_rdoc_files:
|
42
35
|
- README.md
|
43
|
-
files:
|
44
|
-
- .gitignore
|
36
|
+
files:
|
37
|
+
- ".gitignore"
|
45
38
|
- Gemfile
|
46
39
|
- Gemfile.lock
|
47
40
|
- MIT-LICENSE
|
@@ -58,41 +51,31 @@ files:
|
|
58
51
|
- test/dynamic_form_i18n_test.rb
|
59
52
|
- test/dynamic_form_test.rb
|
60
53
|
- test/test_helper.rb
|
61
|
-
|
62
|
-
homepage: http://codaset.com/joelmoss/dynamic-form
|
54
|
+
homepage: http://github.com/joelmoss/dynamic_form
|
63
55
|
licenses: []
|
64
|
-
|
65
|
-
post_install_message:
|
66
|
-
rdoc_options:
|
67
|
-
- --charset=UTF-8
|
68
|
-
require_paths:
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options:
|
59
|
+
- "--charset=UTF-8"
|
60
|
+
require_paths:
|
69
61
|
- lib
|
70
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
|
72
|
-
requirements:
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
73
64
|
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
version: "0"
|
79
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
-
none: false
|
81
|
-
requirements:
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
82
69
|
- - ">="
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
|
85
|
-
segments:
|
86
|
-
- 0
|
87
|
-
version: "0"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
88
72
|
requirements: []
|
89
|
-
|
90
|
-
|
91
|
-
rubygems_version: 1.3.7
|
92
|
-
signing_key:
|
73
|
+
rubygems_version: 3.4.11
|
74
|
+
signing_key:
|
93
75
|
specification_version: 3
|
94
|
-
summary: DynamicForm holds a few helper methods to help you deal with your Rails3
|
95
|
-
|
76
|
+
summary: DynamicForm holds a few helper methods to help you deal with your Rails3
|
77
|
+
models
|
78
|
+
test_files:
|
96
79
|
- test/dynamic_form_i18n_test.rb
|
97
80
|
- test/dynamic_form_test.rb
|
98
81
|
- test/test_helper.rb
|