mongoid_form 0.0.2 → 0.0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/mongoid_form/form_builder.rb +6 -4
- data/lib/mongoid_form/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -23,7 +23,7 @@ It makes your life easy when you develop forms and your app use [mongoid](https:
|
|
23
23
|
# config/initializers/mongoid_form_config.rb
|
24
24
|
...
|
25
25
|
# this option add after label text "<div class=\"flag flags-en\" />" to each locale fo localized fields
|
26
|
-
# you should styling .flag
|
26
|
+
# you should styling .flag and .flags-en (.flags-ru etc.) in your css.
|
27
27
|
flag_for_localized true
|
28
28
|
...
|
29
29
|
```
|
@@ -17,7 +17,7 @@ module MongoidForm
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def error_notification
|
20
|
-
if any_errors?
|
20
|
+
if any_errors? && wrapper.main_error_i18n_key.present?
|
21
21
|
alert { I18n::t(*wrapper.main_error_i18n_key, model: @object.class.model_name.human, count: @object.errors.size) }
|
22
22
|
end
|
23
23
|
end
|
@@ -79,8 +79,6 @@ module MongoidForm
|
|
79
79
|
result = ''
|
80
80
|
I18n.available_locales.each do |locale|
|
81
81
|
field = builder.object_name.scan(/(.*)\[(.*)_translations\]/).join('.')
|
82
|
-
Rails.logger.info "$$$"*10
|
83
|
-
Rails.logger.info wrapper.flag_for_localized.inspect
|
84
82
|
flag = wrapper.flag_for_localized.first ? wrap('', [:div, class: "flag flags-#{locale.to_s}"]) : ''
|
85
83
|
label = builder.label locale.to_sym, *wrapper.label_options do
|
86
84
|
asterisk(name) + I18n::t("mongoid.attributes.#{field}") + flag
|
@@ -107,7 +105,11 @@ module MongoidForm
|
|
107
105
|
end
|
108
106
|
|
109
107
|
def error(name)
|
110
|
-
has_error?(name)
|
108
|
+
if has_error?(name)
|
109
|
+
wrapper.error_block.present? ? wrap(get_error(name), wrapper.error_block) : get_error(name)
|
110
|
+
else
|
111
|
+
''
|
112
|
+
end
|
111
113
|
end
|
112
114
|
|
113
115
|
def get_error(name)
|
data/lib/mongoid_form/version.rb
CHANGED