Hello everyone!
Here is my problem. I have a form to create a ticket, and I want to
upload a file in the same time.
Basically, a user fill the form and then can attach a file while editing
his ticket. But what I want to do here, is to send the file during the
creation of the ticket.
This is the form to create a ticket :
<% form_for(@ticket) do |f| %>
My first field
<%= f.label :subject, 'Subject: '%>
<%= f.text_field :subject, :size => 70 %>
Submit button
<%= f.submit “Create” %>
<% end %>
And I want to add this form (see underneath) into the first form
(mentioned above). But instead of sending POST data for this second
form, I’d like to add this variables as hidden fields in the first form.
<% form_for(@ticket_attachment, :html => { :multipart => true }) do |f|
%>
<label>File: </label>
<%= file_field(:ticket_attachment, :file) %>
<%= hidden_field :ticket_attachment, :first_thing %>
<%= hidden_field :ticket_attachment, :second_thing %>
<%= f.submit "Upload" %>
<% end %>
Is that possible?! Maybe with ajax?
Thank you!