Select list when editing doesn't load saved data

1 view
Skip to first unread message

tilzinger

unread,
Dec 5, 2008, 4:58:25 PM12/5/08
to attribute_fu
Everything is working for me now attribute_fu, except for when I go to
edit a record (in this case a 'contact') it doesn't set the select
list for my list of email attributes (each contact can have multiple
email addresses). Each email address has a type (work, personal etc),
and the problem is that the @contact.email_addresses value that was
already saved is not used to set the selection on the select list when
editing contact. How do I get the type of email address that is saved
with the record to set the selection on the list? Thanks

_contact_category_group.html.erb
<div id="email_addresses">
<h4>Email Addresses</h4>
<div class="add_new"><%= f.add_associated_link "Add",
EmailAddress.new, :partial => 'shared/email_address' %></div>
<%= f.render_associated_form @contact.email_addresses, :new =>
1, :partial => 'shared/email_address' %>
</div>

_email_address.html.erb
<div class="email_address">
<%= f.text_field "value" %>
<%= f.select "category", ContactCategory.get_category
("email_address").collect {|p| [[p.label], [p.short]]} %>
<%= f.remove_link "remove" %>
</div>

tilzinger

unread,
Dec 5, 2008, 5:00:56 PM12/5/08
to attribute_fu
I should mention that ContactCategory.get_category
("email_address").collect is just pulling a list of email types from
another table in the DB, so if the user's email address is of the type
'personal' then as the list is being generated it should set
'personal' as selected.

tilzinger

unread,
Dec 9, 2008, 1:35:56 PM12/9/08
to attribute_fu
Not a very active list here huh? :)
Reply all
Reply to author
Forward
0 new messages