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

Using translated fields with formtastic #1

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

Using translated fields with formtastic #1

tonic20 opened this issue May 14, 2010 · 3 comments

Comments

@tonic20
Copy link

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?

@jo
Copy link
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

@jacobat
Copy link
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 added a commit that referenced this issue Apr 28, 2011
@jo
Copy link
Owner

jo commented Apr 28, 2011

merged. Thank you all.

@jo jo closed this as completed Apr 28, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants