gordon.erlebach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-29 17:01 UTC
form_tag versus form_for with :multipart => true
Consider the following two ways of doing forms, both with :multipart => true. Only the form_for will work properly when using attachment_fu <code> <%= form_tag :action => ''create'', :multipart => true %> <%= file_field ''assignment'', :uploaded_data %> <%= submit_tag "Create" %> <%= end_form_tag %> </code> HTML: <code> <form action="/assignment/create?multipart=true" method="post"> </code> <code> <% form_for :assignment, :url => {:action => ''create''}, :html => {:multipart => true}) do |f| %> <%= file_field :assignment, :uploaded_data %> <%= submit_tag "Upload Assignment" %> <% end %> </code> HTML: <code> <form action="/assignment/create" enctype="multipart/form-data" method="post"> <input id="assignment_uploaded_data" name="assignment[uploaded_data]" size="30" type="file" /> <input name="commit" type="submit" value="Upload Assignment" /> </form> </code> Only the second form works with attachment_fu. Why are these two translations incompatible? I would expect the enctype to be specified on the first form above. Thanks for any feedback, Gordon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 8/29/07, gordon.erlebach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <gordon.erlebach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Consider the following two ways of doing forms, both with :multipart > => true. Only > the form_for will work properly when using attachment_fu > > <code> > <%= form_tag :action => ''create'', :multipart => true %> > <%= file_field ''assignment'', :uploaded_data %> > <%= submit_tag "Create" %> > <%= end_form_tag %> > </code> > > HTML: > <code> > <form action="/assignment/create?multipart=true" method="post"> > </code> > > <code> > <% form_for :assignment, :url => {:action => ''create''}, :html => > {:multipart => true}) do |f| %> > <%= file_field :assignment, :uploaded_data %> > <%= submit_tag "Upload Assignment" %> > <% end %> > </code> > > HTML: > > <code> > <form action="/assignment/create" enctype="multipart/form-data" > method="post"> > <input id="assignment_uploaded_data" > name="assignment[uploaded_data]" size="30" type="file" /> > <input name="commit" type="submit" value="Upload Assignment" /> > </form> > </code>the :multipart specification goes into the options hash for the form_tag, such as the following: <% form_tag({:action => ''settings''}, {:multipart => true, :class => "form-style2"} ) do -%> ... <% end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---