Rails form submission
Posted
by Danny McClelland
on Stack Overflow
See other posts from Stack Overflow
or by Danny McClelland
Published on 2010-04-23T13:08:38Z
Indexed on
2010/04/23
13:33 UTC
Read the original article
Hit count: 432
ruby-on-rails
|forms
Hi Everyone,
I have a simple form to enter details of a new case (kase), it's working well and clicking submit stores the information and takes the user to the show.html.erb page. However, I wanted to move part of the form to the sidebar - to make things a little easier to see and use for the user, however, when I moved the section to the sidebar - anything entered during either a creation or edit within those sidebar fields is ignored. Any idea how I keep the fields in the sidebar, but include them as before?
<% content_for :header do -%>
Cases
<% end -%>
<% form_for(@kase) do |f| %>
<%= f.error_messages %>
<!-- #START SIDEBAR -->
<% content_for :sidebar do -%>
<% if @kase.avatar.exists? then %>
<%= image_tag @kase.avatar.url %>
<% else %>
<p style="font-size:smaller"> You can upload an icon for this case that will display here. Usually this would be for the year number icon for easy recognition.</p>
<% end %>
<div class="js_option">
<h2>Financial Options</h2><p class="finance_showhide"><%= link_to_function "Show","Element.show('finance_showhide');" %> / <%= link_to_function "Hide","Element.hide('finance_showhide');" %></p>
</div>
<div id="finance_showhide" style="display:none">
<ul id="kases_new_finance">
<li>Invoice Number<span><%= f.text_field :invoicenumber %></span></li>
<li>Net Amount<span><%= f.text_field :netamount %></span></li>
<li>VAT<span><%= f.text_field :vat %></span></li>
<li>Gross Amount<span><%= f.text_field :grossamount %></span></li>
<li>Date Closed<span><%= f.text_field :dateclosed %></span></li>
<li>Date Paid<span><%= f.text_field :datepaid %></span></li>
</ul>
</div>
<% end -%>
<!-- #END SIDEBAR -->
<% form_for (@kase), :html => { :multipart => true } do |f| %>
<ul id="kases_new">
<li>Job Ref.<span><%= f.text_field :jobno %></span></li>
<li>Case Subject<span><%= f.text_field :casesubject %></span></li>
<li>Transport<span><%= f.text_field :transport %></span></li>
<li>Goods<span><%= f.text_field :goods %></span></li>
<li>Date Instructed<span><%= f.date_select :dateinstructed %></span></li>
<li>Case Status<span><%= f.select "kase_status", ['Active', 'On Hold', 'Archived', 'Invoice Sent'] %></span></li>
<li>Client Reference<span><%= f.text_field :clientref %></span></li>
<li>Client Company Name<span><%= f.text_field :clientcompanyname %></span></li>
<li>Client Company Address<span><%= f.text_field :clientcompanyaddress %></span></li>
<li>Client Company Fax<span><%= f.text_field :clientcompanyfax %></span></li>
<li>Case Handler Name<span><%= f.text_field :casehandlername %></span></li>
<li>Case Handler Tel<span><%= f.text_field :casehandlertel %></span></li>
<li>Case Handler Email<span><%= f.text_field :casehandleremail %></span></li>
<li>Claimant Name<span><%= f.text_field :claimantname %></span></li>
<li>Claimant Address<span><%= f.text_field :claimantaddress %></span></li>
<li>Claimant Contact<span><%= f.text_field :claimantcontact %></span></li>
<li>Claimant Tel<span><%= f.text_field :claimanttel %></span></li>
<li>Claimant Mob<span><%= f.text_field :claimantmob %></span></li>
<li>Claimant Email<span><%= f.text_field :claimantemail %></span></li>
<li>Claimant URL<span><%= f.text_field :claimanturl %></span></li>
<li>Comments<span><%= f.text_field :comments %></span></li>
</ul>
<p>
<%= f.submit "Create" %>
</p>
<% end %><% end %>
<%= link_to 'Back', kases_path %>
© Stack Overflow or respective owner