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

Already on GitHub? Sign in to your account

Using translated fields with formtastic #1

Closed
tonic20 opened this Issue May 14, 2010 · 3 comments

Comments

Projects
None yet
3 participants

tonic20 commented May 14, 2010

Thank you for nice plugin. I have a problem when I use translated fields in forms with Formtastic.

When I use in views:
= semantic_form_for [:admin, @page] do |f|
= f.inputs do
= f.input :title
= f.buttons

Field title not shown correctly. Workaround is to use in forms proxy field, like title_translated below:

class Post < ActiveRecord::Base
  puret :title

  # proxy for translated field
  def title_translated=(s)
    self.title = s
  end

  def title_translated
    title
  end
end

Then:
= semantic_form_for [:admin, @page] do |f|
= f.inputs do
= f.input :title_translated
= f.buttons

Works fine. How can I use translated fields in forms without such proxy fileds?

Owner

jo commented May 25, 2010

Seems like this is an issue only with formtastic.

Maybe formtastic looks into the attributes hash of ActiveModel.
Since I do not use that plugin, I won't dig deeper.

But a patch is greatly appreciated!

Greetings
Johannes

Contributor

jacobat commented Apr 28, 2011

Actually this is a problem with plain Rails forms too. I just created a new Rails project to try it out:

rails new purettest
cd purettest
echo "gem 'puret'" >> Gemfile
bundle
rails generate scaffold post title:string description:text
rake db:migrate
rails generate puret:model Post title:string description:text
rake db:migrate
rails server

Go to /posts, create a new post and then try editing it, you will see that the form field is not prefilled.

@jo jo added a commit that referenced this issue Apr 28, 2011

@jo jo Merged pull request #5 from jacobat/master.
Fix for issue #1
ec7100e
Owner

jo commented Apr 28, 2011

merged. Thank you all.

@jo jo closed this Apr 28, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment