Open alecslupu opened 4 years ago
Overwrite views/rails_admin/main/_form_globalize_tabs.html.haml with this:
- uuid = SecureRandom.uuid
.controls
%ul.nav.nav-tabs{ :style => 'margin-top:5px' }
- field.tabs.each do |tab|
%li{ class: ('active' if tab.active?) }
= link_to tab.label, "#", data: { toggle: "tab", target: "##{tab.id}-#{uuid}" }, class: ('text-danger' unless tab.valid?)
.tab-content
- field.tabs.each do |tab|
= form.fields_for field.name, tab.translation, wrapper: false do |f|
.fields.tab-pane{ id: "#{tab.id}-#{uuid}", class: ('active' if tab.active?) }
= f.generate(action: :nested, model_config: field.associated_model_config, nested_in: field)
@sasselin It works, thank you!
When rails_admin_globalize_field widget is used within a nested object, it does not work properly, as the tabs are not properly switched. In this particular case, there will be more DOM elements with the same id. I have tried to inject an unique string within https://github.com/scarfacedeb/rails_admin_globalize_field/blob/master/lib/rails_admin_globalize_field/globalize_tabs.rb#L31 , however, the approach dis not worked as expected. I think a different tab binding should be used.
Using:
===
Having the models set up like:
And the following Rails admin setup
I get some some strange behavior regarding the tabbing when trying to add multiple Poll Option entries. The tabbing is activated on model level (meaning i can browse through the Poll Option forms), however, the translations (which are also tabbed are not working). when clicking on on the language, the selected tab becomes active, but the tab-pane is not being changed.
I get the same behavior when trying to edit a poll that has 2 options. The tab-panes in the second object is not correctly activated.