Folks,
I have a shopping cart app that asks users for their shipping address,
and then asks them to click a checkbox if they have a different billing
address. There''s an event listener on the checkbox that detects the
click and renders a partial containing a series of new form fields for
the billing address. Works fine. Except that the user input in the
billing address fields isn''t being captured in params or saved to the
model. I have an app w/ identical functionality to this that works
fine, and I can''t figure out what''s going wrong. I''d
be grateful for
any suggestions.
### main view
<%= form_tag({:action => ''save_customer''}, :multipart
=> true) %>
<%= javascript_include_tag ''prototype''  %>
<h3>Please enter your details below</h3>
 <div>
 <label for="name">Name</label><br/>
  <%= text_field("customer", "name", "size"
=> 40 ) %><br />
 </div>
 <div>
  <label for="email">Your e-mail
address</label><br/>
 <%= text_field("customer", "email", "size"
=> 40 ) %>
 </div>
<label for="ship_address1">Your shipping
address</label><br/>
 <%= text_field("customer", "ship_address1",
"size" => 40 ) %>
 </div>
 <div>
  <label for="email">Address line 2</label><br/>
 <%= text_field("customer", "ship_address2",
"size" => 40 ) %>
 </div>
 <div>
  <label for="bill_city">City</label><br/>
 <%= text_field("customer", "ship_city", "size"
=> 40 ) %>
 </div>
<div>
  <label for="bill_state">State</label><br/>
 <%options = [["Select a state", ""]] +
Customer::STATE_NAMES
select("customer", "ship_state", options)
%>
</div>
 <div>
  <label for="bill_zip">Zipcode</label><br/>
 <%= text_field("customer", "ship_zip", "size"
=> 10 ) %>
 </div>
<div>
  <label for="bill_state">Country</label><br/>
 <%options = [["Select a country", ""]] +
Customer::COUNTRY_NAMES
select("customer", "ship_country", options)
%>
</div>
<div>
  <label for="different_bill">Check if you have a different
billing
address</label><br/>
<%= check_box_tag("different_bill") %>
</div>
<%= observe_field(:different_bill,  :update => "billinfo", :url
=> {
:controller=>''shirts'', :action =>
''billing_address'' }, :with =>
"''id=''+value"  ) %>
<p id="billinfo"></p>
<div>
  <label for="pay_type">Payment method</label><br/>
<select id="pay_type" name="pay_type"><option
selected="yes"></option><option>Credit
Card</option><option>Paypal</option>
</select>
</div>
<div>
<br />
<%= submit_tag "Save" %>
</div>
<%= end_form_tag %>
### partial -- _billinfo.rhtml
<label for="bill_address1">Your billing
address</label><br/>
 <%= text_field("customer", "bill_address1",
"size" => 40 ) %>
 </div>
 <div>
  <label for="email">Address line 2</label><br/>
 <%= text_field("customer", "bill_address2",
"size" => 40 ) %>
 </div>
 <div>
  <label for="bill_city">City</label><br/>
 <%= text_field("customer", "bill_city", "size"
=> 40 ) %>
 </div>
<div>
  <label for="bill_state">State</label><br/>
 <%options = [["Select a state", ""]] +
Customer::STATE_NAMES
select("customer", "bill_state", options)
%>
</div>
 <div>
  <label for="bill_zip">Zipcode</label><br/>
 <%= text_field("customer", "bill_zip", "size"
=> 10 ) %>
 </div>
<div>
  <label for="bill_state">Country</label><br/>
 <%options = [["Select a country", ""]] +
Customer::COUNTRY_NAMES
select("customer", "bill_country", options)
%>
</div>
### controller action
	def billing_address
	  if  params[:id] == "1"
	  render :partial => ''billinfo'', :layout => false
     else
        render :nothing=>true
     end
    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
-~----------~----~----~----~------~----~------~--~---