Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ end
```
## In your Active Admin resource definition

**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
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.

```ruby

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

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

# Instead you have to nest the block inside an #inputs block and the title
# should be passed to the inputs method
form do |f|
# ...
f.inputs "Translated fields" do
f.translated_inputs 'ignored title', switch_locale: false do |t|
t.input :title
t.input :description
end
end
# ...
end

# You can also set locales to show in tabs
# For example we want to show English translation fields without tab, and want to show other languages within tabs
form do |f|
Expand Down
4 changes: 4 additions & 0 deletions lib/active_admin/globalize/form_builder_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def translated_inputs(name = "Translations", options = {}, &block)
available_locales = options.fetch(:available_locales, I18n.available_locales)
switch_locale = options.fetch(:switch_locale, false)
default_locale = options.fetch(:default_locale, I18n.default_locale)
if block_given?
# If this translated_inputs is nested inside an inputs, AA has already set this
template.assigns[:has_many_block] = true
end
template.content_tag(:div, class: "activeadmin-translations") do
template.content_tag(:ul, class: "available-locales") do
available_locales.map do |locale|
Expand Down