Pawel Jur wrote:> Hello
>
>
> Is it possible to add and remove file_field_tags on the fly on a form
> using only rails code and rjs?
>
> If so can someone provide a solution.
If you just want to add a new input,
then simply increment a session variable or something
% _file_fields.rhtml
<div id="file_field_div">
</div>
<%= link_to_remote("Add new input", :action =>
"add_new_input") %>
% _file_field.rhtml
<%= file_field_tag("file[@file_number]") %>
% file_controller.rb
def add_new_input
session[:file_number] ||= 0
session[:file_number] += 1
@file_number = session[:file_number]
end
% add_new_input.rjs
page.insert_html :bottom, "file_field_div", :partial =>
"file_field"
--
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
-~----------~----~----~----~------~----~------~--~---