Skip to content

Commit c12deac

Browse files
committed
Fix translated_inputs not properly setting up user block capture (#4)
1 parent 6cd5174 commit c12deac

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

README.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ end
3737
```
3838
## In your Active Admin resource definition
3939

40-
**Important note:** I'm working on a fix for #4 because after AA deprecated and then removed [#form_buffers](https://github.com/activeadmin/activeadmin/pull/3486) the
41-
syntax shown below for form declaration doesn't work as is. See comments in code and [discussion](#4) to fix it until I found a solution.
42-
4340
```ruby
4441

4542
# For usage with strong parameters you'll need to permit them
@@ -54,7 +51,6 @@ index do
5451
actions
5552
end
5653

57-
# This was the original syntax proposed in this gem, however currently it doesn't work
5854
form do |f|
5955
# ...
6056
f.translated_inputs "Translated fields", switch_locale: false do |t|
@@ -64,19 +60,6 @@ form do |f|
6460
# ...
6561
end
6662

67-
# Instead you have to nest the block inside an #inputs block and the title
68-
# should be passed to the inputs method
69-
form do |f|
70-
# ...
71-
f.inputs "Translated fields" do
72-
f.translated_inputs 'ignored title', switch_locale: false do |t|
73-
t.input :title
74-
t.input :description
75-
end
76-
end
77-
# ...
78-
end
79-
8063
# You can also set locales to show in tabs
8164
# For example we want to show English translation fields without tab, and want to show other languages within tabs
8265
form do |f|

lib/active_admin/globalize/form_builder_extension.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ def translated_inputs(name = "Translations", options = {}, &block)
88
available_locales = options.fetch(:available_locales, I18n.available_locales)
99
switch_locale = options.fetch(:switch_locale, false)
1010
default_locale = options.fetch(:default_locale, I18n.default_locale)
11+
if block_given?
12+
# If this translated_inputs is nested inside an inputs, AA has already set this
13+
template.assigns[:has_many_block] = true
14+
end
1115
template.content_tag(:div, class: "activeadmin-translations") do
1216
template.content_tag(:ul, class: "available-locales") do
1317
available_locales.map do |locale|

0 commit comments

Comments
 (0)