Edit form


#1

Hello
am a newbie :slight_smile:
am developing a portal for employees company. there is an edit form that
allows employees to change their information ( phone number, address,
etc)
here is the employees controller

def contact_information
current_user= session[:login]

@contact_information= Employee.find_by_sql( "select * from employees

where id=’#{current_user}’")
end

in the form i have :

<% for obj in @contact_information%>

<% form_tag :action => 'save_contact_information', :employee=>@employee do %>
  </table>

</td>
<td width="48%" rowspan="2" valign="top"> <table width="99%"

border=“0” align=“center” cellpadding=“0” cellspacing=“0”
class=“subtable”>































  </table></td>
Work
Work Location <%= text_field 'employee', 'work_location' ,:maxlength => 50,:size=>25,:value=>obj.work_location %>
Work State <%= text_field 'employee', 'work_state_id' ,:maxlength => 50,:size=>25%>
Work Phone <%= text_field 'employee', 'work_phone' ,:maxlength => 50,:size=>25,:value=>obj.work_phone %>
Mobile Phone <%= text_field 'employee', 'mobile_phone' ,:maxlength => 50,:size=>25,:value=>obj.mobile_phone %>
Work Fax <%= text_field 'employee', 'work_fax' ,:maxlength => 50,:size=>25,:value=>obj.work_fax %>
Work Email <%= text_field 'employee', 'work_email' ,:maxlength => 50,:size=>25,:value=>obj.work_email %>
Permanent
Home
Address 1 <%= text_field ‘employee’, ‘street_address1’
,:maxlength => 50,:size=>25,:value=>obj.street_address1 %>
Address 2 <%= text_field ‘employee’, ‘street_address2’ ,:maxlength
=> 50,:size=>25,:value=>obj.street_address2 %>
City <%= text_field ‘employee’, ‘city’ ,:maxlength =>
50,:size=>25,:value=>obj.city%>
State <%= select ‘employee’,‘state_id’, State.find(:all).collect
{|c| [c.state_name, c.id]},{:selected=>obj.state_id}%>
Postal code <%= text_field ‘employee’, ‘postal_code’ ,:maxlength =>
50,:size=>25,:value=>obj.postal_code%>
Country <%= country_select ‘employee’, ‘country’ %>
Home Phone <%= text_field ‘employee’, ‘home_phone’ ,:maxlength =>
50,:size=>25,:value=>obj.home_phone%>
Current Home
Address 1 <%= text_field 'employee', 'present_street_address1' ,:maxlength => 50,:size=>25,:value=>obj.present_street_address1 %>
Address 2 <%= text_field 'employee', 'present_street_address2' ,:maxlength => 50,:size=>25,:value=>obj.present_street_address2 %>
city <%= text_field 'employee', 'present_city' ,:maxlength => 50,:size=>25,:value=>obj.present_city%>
State <%= select 'employee','present_state_id', State.find(:all).collect {|c| [c.state_name, c.id]},{:selected=>obj.present_state_id}%>
Postal code <%= text_field 'employee', 'present_postal_code' ,:maxlength => 50,:size=>25,:value=>obj.present_postal_code%>
Country <%= country_select 'employee', 'present_country' %>
Mobile Phone <%= text_field 'employee', 'mobile_phone' ,:maxlength => 50,:size=>25,:value=>obj.mobile_phone%>
Personal Email <%= text_field 'employee', 'personal_email' ,:maxlength => 50,:size=>25,:value=>obj.personal_email%>
<%= submit_tag "Save all changes"%>
<%end%> <%end%>

the problem is when an employee open this page, countrie_selct always
shows the first country ( Afghanistan) while it should show something
else ( India for example), as well as for states.
any help will be much appreciated
Thank you
Feras,