How to get value from partial


#1

Hi, I’m really confused on how I should do it as I have a form as:

================================================================================
<%form_for :cart do |form|%>

Campgrounds
<%= form.select "campsite", %w{ ---- }, :class => "select_campsites" %>

Arrival Date:
<%= form.text_field :arrival_date %>

Nights:
<%= form.text_field :nights %>

Parents:
<%= form.text_field :parents %>

Children:
<%= form.text_field :children %>

Family Rate:
<%= form.check_box "family_claim",{}, "1", "0"%>

<%=submit_tag “Calculate”%>
<%end%>

Now div with the :id “campsites_list” gets updated with the
_campsites.rhtml partial when ever I change the value of another combo
box.

_campsites.rhtml

Campgrounds
<%=select "camp", "id", @resultset %>

================================================================================

I’m trying to save all the above details with
@cart=Cart.new(params[:cart]) all gets saved except the value from the
combo box so how can I save it as well… thanks.


#2

Or is it possible that i get all the textfield values from params[:cart]
and the value of the combo box with params[:camp][:id] and squeeze them
together and pass to Cart.new(squeezed_object)
thanks…


#3

Could it be that your select for “camp” isn’t part of the form?

View source for your page in the browser to make sure that your select
is indeed part of the form, and that data should come back to you.


#4

Ar Chron wrote:

Could it be that your select for “camp” isn’t part of the form?

View source for your page in the browser to make sure that your select
is indeed part of the form, and that data should come back to you.

Ya, I couldn’t find it in the view source. I loaded that partial with
updated values and then viewed the source but still its showing the code
for the previous combo box only…


#5

On Oct 10, 1:38 am, Jay P. removed_email_address@domain.invalid
wrote:

_campsites.rhtml

Campgrounds
<%=select "camp", "id", @resultset %>

================================================================================

Shouldn’t the select field in the partial be part of the form? IE:
<%= form.select “camp”, “id”, @resultset %>

Notice the “<%= form.select” in comparison to the original “<
%=select”.

Hope that helps.
-Nick
–~--~---------~–~----~------------~-------~–~----~
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 removed_email_address@domain.invalid
To unsubscribe from this group, send email to
removed_email_address@domain.invalid
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~–~—


#6

Nick wrote:

Shouldn’t the select field in the partial be part of the form? IE:
<%= form.select “camp”, “id”, @resultset %>

Notice the “<%= form.select” in comparison to the original “<
%=select”.

Hope that helps.
-Nick

<%= form.select “camp”, “id”, @resultset %> is an error coz the word
form is no where to be found in the _campsites.rhtml. I tried using
<%form_for :cart do |form|%><%end%> in partial file as well, but that
stopped the updating of the

with this partial. So, couldn’t get
thru…

#7

On Oct 10, 1:38 am, Jay P. removed_email_address@domain.invalid
wrote:

<label for = "arrival date">Arrival Date:</label><br />
<%= form.text_field :arrival_date %>

By the way, you should also use the #label method, like this:

<%= form.label :arrival_date, ‘Arrival Date:’ %>

Cheers,
Nick