Open raelgc opened 1 year ago
Hi, @raelgc did you got any luck with this? Things are also not working for rails 7. @scarfacedeb
No luck, same issue with rails 7 too. Basically I've got ride of this gem and, as in our project we have only 1 admin, we've are leaving now with the raw i18n entries.
Since haml
format is no longer supported in new rails_admin 3
, we need to override the template, using erb
format for example.
Right now I have the form showing BUT the issue that I have right now is that it doesn't update my translation fields when saving the form.
Do you have an idea of what I need to change to make my nested form updates the fields?
<%# create a file app/views/rails_admin/main/_form_globalize_tabs.html.erb and put the code below %>
<div class="controls">
<ul class="nav nav-tabs" role="tablist" style="margin-top:5px">
<% field.tabs.each do |tab| %>
<li class="nav-item" role="presentation">
<button class="nav-link<%= (" active" if tab.active?) %><%= " text-danger" unless tab.valid? %>" id="<%= tab.label %>-tab" data-bs-toggle="tab" data-bs-target="#<%= tab.label %>" type="button" role="tab" aria-controls="<%= tab.label %>" aria-selected="true"><%= tab.label %></button>
</li>
<% end %>
</ul>
</div>
<div class="tab-content">
<% field.tabs.each do |tab| %>
<%= form.fields_for field.name, tab.translation, wrapper: false do |f| %>
<div class="tab-pane fade<%= (' show active' if tab.active?) %> fields" id="<%= tab.label %>" role="tabpanel" aria-labelledby="<%= tab.label %>-tab">
<%= f.generate(action: :nested, model_config: field.associated_model_config, nested_in: field) %>
</div>
<% end %>
<% end %>
</div>
Yes, did the same but fails to add new or edit, says translation missing even when they are filled.
what I think is some code is failing in /lib/rails_admin_globalize_field/tab.rb
on initialize method
or in lib/rails_admin_globalize_field/globalize_tabs.rb
on tabs method
as while debugging I found that the translations records are not initializing even though the params have the value of the translation in the correct nested format. No feasible solution found yet still debugging it :(
I don't have this issue. All those methods are being triggered when I put breakpoints and it's all good. Probably you missed something in configuration file? My problem is that even with those methods working good and my template showing correctly, the PUT
form doesn't push my fields to params
and it doesn't save.
here's my configuration
models/category.rb
class Category < ApplicationRecord
# ...
translates :eligible, :name
accepts_nested_attributes_for :translations, allow_destroy: true
# ...
end
config/initializers/rails_admin.rb
RailsAdmin.config do |config|
# ...
config.included_models = %w(Category Category::Translation)
config.model 'Category' do
configure :translations, :globalize_tabs
end
# ...
end
While using:
3.1.2
6.1.7
3.0.0
1.2.0
I'm getting the following error while trying to edit any model: