Support i18n and select options user attributes, but admin edit is broken

This commit is contained in:
Wen-Tien Chang committed 2010-03-18 17:57:26 +08:00
1 parent bebc51e8bb
commit 554aa0a95d
4 files changed
+31 -9

No files matched your search

+1 -1
View File
@@ -4,6 +4,6 @@ class UserAttribute
key :key, String
key_i18n :name, String
key_i18n :attrs, Array
key :attrs, Array
end
@@ -9,7 +9,7 @@
<label><%= attr["key"] %></label>
<%= hidden_field_tag "user_attribute[attrs][][key]", attr["key"] %>
<%= text_field_tag "user_attribute[attrs][][name]", attr["name"] %>
<%= select_tag "user_attribute[attrs][][type]", options_for_select(["text_field"], attr["type"]) %>
<%= select_tag "user_attribute[attrs][][type]", options_for_select(["text_field", "select"], attr["type"]) %>
<a href="#" class="remove">(remove)</a>
</p>
<% end -%>
+23 -4
View File
@@ -17,10 +17,29 @@
<h3><%= ua.name %></h3>
<% ua.attrs.each do |attr| %>
<p>
<%= f.label attr["name"] %>
<%= f.send(attr["type"], "#{ua.key}_#{attr["key"]}" )%>
</p>
<% if attr["locale"] %>
<p>
<%= f.label attr["name_#{I18n.locale}"] %>
<% if attr["type"] == "text_field" %>
<% VALID_LOCALES.each do |locale| %>
<%= f.text_field "#{ua.key}_#{attr["key"]}_#{locale}" %>(<%= locale %>)
<% end -%>
<% elsif attr["type"] == "select" %>
<%= f.select "#{ua.key}_#{attr["key"]}_#{I18n.locale}", attr["options_#{I18n.locale}"].to_a %>
<% end -%>
</p>
<% else %>
<p>
<%= f.label attr["name"] %>
<% if attr["type"] == "text_field" %>
<%= f.text_field "#{ua.key}_#{attr["key"]}" %>
<% elsif attr["type"] == "select" %>
<%= f.select "#{ua.key}_#{attr["key"]}", attr["options"].to_a %>
<% end -%>
</p>
<% end -%>
<% end -%>
</div>
<% end -%>