I need a way to replace a table row with a form to edit it''s values --
kind of like edit-in-place, only that I need a custom form (check boxes,
select lists, text fields, etc). My table is generated with a partial of
a model.
The row should have a button/link to enable to go in and out of edit
mode, and this should be done asynchronously. Here''s what I came up
with
so far:
# view
<div id="people_table">
<table>
<%= render :partial => ''person'', :collection =>
@people %>
</table>
</div>
# partial
<% @person = person -%>
<% @row_id = "person_#{person.id}" %>
<tr id="person_<%= person.id %>">
<td><%= link_to_remote ''edit'', :url => { :action
=> ''edit_row''}
%></td>
<td><%= person.name %></td>
<td><%= person.age %></td>
</tr>
I need help with the controller and how to replace the specific row
(with id="person_<nn>") with a form. Should the form be hidden
in the
partial and controlled by a boolean passed to it (if true, show form >
else show the normal view)? meaning:
<% if edit_mode -%>
<% form_for :person do |f| -%>
<td><%= f.text_field :name %></td>
<td><%= f.text_field :age %></td>
<td><%= f.submit ''go'' %></td>
<% end -%>
<% else -%>
<td><%= link_to_remote ''edit'', :url => { :action
=> ''edit_row''}
%></td>
<td><%= person.name %></td>
<td><%= person.age %></td>
<% end -%>
I can''t be the only one who''s trying to do this, so
I''d really
appreciate any thoughts, insights and such. Thanks in advance!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---