Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translated_inputs - only last input is rendered #4

Open
ghost opened this issue Nov 12, 2014 · 13 comments
Open

translated_inputs - only last input is rendered #4

ghost opened this issue Nov 12, 2014 · 13 comments
Labels

Comments

@ghost
Copy link

ghost commented Nov 12, 2014

Thank you for the new version in the develop branch. I've tested it now and it seems to work except for one issue:

When generating a form like the following:

f.translated_inputs "General", switch_locale: true do |t|
t.input :description
t.input :name
end

Only the first t.input is rendered. The second is ignored.

Could you please have another look into this. Thank you!

@fabn
Copy link
Owner

fabn commented Nov 12, 2014

So, you're having inputs for all locales for name field and description input is completely misssing?

@fabn
Copy link
Owner

fabn commented Nov 12, 2014

Also, what happens if you add another field to that block?

@ghost
Copy link
Author

ghost commented Nov 12, 2014

No, only the :desciption field is rendered. The :name field is completely missing. (see attached screenshot)
screenshot

If I make :name the first field, only :name is rendered and :description is missing.

@ghost
Copy link
Author

ghost commented Nov 12, 2014

I've tested it now with 3 fields in different positions. Every time, only the last field is rendered.

@fabn
Copy link
Owner

fabn commented Nov 12, 2014

That's interesting, because if the rendered field is the last one I have an idea of what is happening. It's like when you're using arbre with rails helpers as in

li { 3.times { |i| link_to(i, '#')  } } # this will show only last link
li { 3.times { |i| text_node link_to(i, '#')  } } # this will show all links

In original report you're saying that the shown input is the first one and with 3 inputs only last is rendered, is that correct?

@ghost
Copy link
Author

ghost commented Nov 12, 2014

Sorry, I mixed that up in my first report. I've double checked it now: it's always the last input that is shown, so your idea seems to be correct...

fabn added a commit that referenced this issue Nov 12, 2014
@fabn
Copy link
Owner

fabn commented Nov 12, 2014

I've updated AA to the latest github version and I'm not able to reproduce your issue. There is a tested resource which should resemble your configuration and with the latest AA and formtastic the issue does not happen. Could you post your AA and formtastic exact versions from bundle show output?

Also native has_many method in AA should have a similar behavior and I found this recent commit in AA which changes that method. I reproduced that commit in translated_inputs code, could you try to run your code against that commit and see if it works?

gem 'activeadmin-globalize', '~> 1.0.0.pre', github: 'fabn/activeadmin-globalize', branch: 'test-fix'

@ghost ghost changed the title translated_inputs - only first input is rendered translated_inputs - only last input is rendered Nov 12, 2014
@ghost
Copy link
Author

ghost commented Nov 12, 2014

I've tried the test-fix branch without success. The issue remains.

Gems included by the bundle:

  • actionmailer (4.1.7)
  • actionpack (4.1.7)
  • actionview (4.1.7)
  • activeadmin (1.0.0.pre 05c3128)
  • activeadmin-globalize (1.0.0.pre cd2db78)
  • activemodel (4.1.7)
  • activerecord (4.1.7)
  • activesupport (4.1.7)
  • arbre (1.0.2)
  • arel (5.0.1.20140414130214)
  • bcrypt (3.1.9)
  • bourbon (3.2.3)
  • builder (3.2.2)
  • bundler (1.6.3)
  • cancancan (1.9.2)
  • choice (0.1.6)
  • coffee-rails (4.1.0)
  • coffee-script (2.3.0)
  • coffee-script-source (1.8.0)
  • devise (3.4.1)
  • erubis (2.7.0)
  • execjs (2.2.2)
  • formtastic (3.0.0)
  • formtastic_i18n (0.1.1)
  • globalize (4.0.2)
  • globalize-accessors (0.1.5)
  • has_scope (0.6.0.rc)
  • hike (1.2.3)
  • i18n (0.6.11)
  • inherited_resources (1.5.1)
  • jbuilder (2.2.4)
  • jquery-rails (3.1.2)
  • jquery-ui-rails (5.0.2)
  • json (1.8.1)
  • kaminari (0.16.1)
  • libv8 (3.16.14.7)
  • mail (2.6.3)
  • mime-types (2.4.3)
  • minitest (5.4.3)
  • multi_json (1.10.1)
  • mysql2 (0.3.17)
  • orm_adapter (0.5.0)
  • pdf-core (0.4.0)
  • polyamorous (1.1.0)
  • prawn (1.3.0)
  • rack (1.5.2)
  • rack-test (0.6.2)
  • rails (4.1.7)
  • rails-erd (1.1.0)
  • railties (4.1.7)
  • rake (10.3.2)
  • ransack (1.5.1)
  • ref (1.0.5)
  • responders (1.1.2)
  • ruby-graphviz (1.0.9)
  • sass (3.2.19)
  • sass-rails (4.0.4)
  • spring (1.1.3)
  • sprockets (2.11.3)
  • sprockets-rails (2.2.0)
  • therubyracer (0.12.1)
  • thor (0.19.1)
  • thread_safe (0.3.4)
  • tilt (1.4.1)
  • ttfunk (1.4.0)
  • turbolinks (2.5.2)
  • tzinfo (1.2.2)
  • uglifier (2.5.3)
  • warden (1.2.3)

@ghost
Copy link
Author

ghost commented Nov 19, 2014

I've tried several versions now but also the test-fix branch does not work for me. I tried to set up a complete new project to test it but without success. Everytime, only the last t.input is rendered.

For the moment, I ended up doing something like

      f.input :name_de
      f.input :name_en
      f.input :description_de
      f.input :description_en

with the globalize-accessors gem.

Do you have any solution yet?

@fabn
Copy link
Owner

fabn commented Nov 19, 2014

I wasn't able to reproduce your issue yet. I have a couple of apps running this code and both run fine. Also the embedded test application works.

If you have a full project which reproduce the issue please share it on github and I'll try to work on this issue as soon as I have some spare time. A minimal new rails app with the issue would be enough to try to fix this.

@ghost
Copy link
Author

ghost commented Nov 22, 2014

Finally I have a trace now:

In a clean new project, when I do something like

  form do |f|
    f.semantic_errors # shows errors on :base

    f.inputs 'General' do
      f.input :name
    end

    f.translated_inputs "Details", switch_locale: true do |t|
      t.input :description
      t.input :interests
      t.input :presets
    end

     f.actions

  end

there is no problem. But when I reverse the two sections, namely:

  form do |f|
    f.semantic_errors # shows errors on :base

    f.translated_inputs "Details", switch_locale: true do |t|
      t.input :description
      t.input :interests
      t.input :presets
    end

    f.inputs 'General' do
      f.input :name
    end

     f.actions

  end

the problem described arises.

So, only when f.translated_inputs is the first item in the form the issue exists.

@fabn
Copy link
Owner

fabn commented Apr 27, 2015

@gerdhuebscher sorry for a such long time to answer. I was finally able to reproduce the issue. The issue happens only when f.translated_inputs is used at top level element for the form. Could you wrap your fields into a f.inputs block?

    f.inputs 'Details' do
      f.translated_inputs "Details", switch_locale: true do |t|
        t.input :description
        t.input :interests
        t.input :presets
      end
    end

P.S. Latest develop is tested now against released activeadmin. I'll try to fix the issue and to clean the api to use it as in your example.

@tobsch
Copy link

tobsch commented Aug 3, 2018

any progress, @mauriciopasquier :) ?

tkalliom added a commit to tkalliom/activeadmin-globalize that referenced this issue Apr 11, 2022
tkalliom added a commit to tkalliom/activeadmin-globalize that referenced this issue Apr 11, 2022
tkalliom added a commit to tkalliom/activeadmin-globalize that referenced this issue Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants