Hi,
I have a very simple page with a drop down select list and I want that a
portion of this page gets updated each time a new selection is done on
the select list.
This is my page with the select list (edit view_sites.html.erb):
<% form_for :site, :url => { :action => :edit_site } do |form| %>
<div id="content">
  <p>
    <%= form.label(:name, "Location Code:") %>
    <%= collection_select(:VMetaLocationPopulated, :location_code,
loc_entities,
    :location_code, :location_code, options ={:prompt => "-Select a
Location Code"}) %>
    <!--Observe the select field and forward to update_edit_view.erb-->
    <%= observe_field
''VMetaLocationPopulated_location_code'',
    :url => {:action => :update_edit_view, :form_authenticity_token =>
form_authenticity_token },
    :update => :dynamic_content,
    :with => ''"locid="+element.value'',
    :locals => { :form => form },
    :loading => "Element.show(''indicator'')",
    :complete => "Element.hide(''indicator'')"
%>
    <br>
    <div id="dynamic_content">
      <!-- see update_edit_view.erb-->
    </div>
  </p>
</div>
<% end %>
And the action method (update_edit_view) in the controller class is
empty since I just want it to forward to the dynamic_content page. So
this is that page (update_edit_view.erb):
<%if(params[:locid] != nil)%>
  <%= form.label(:name, "Location Name:") %>
  <%= form.text_field(:locid, :size => 40) %>
<%else%>
<!-- Do nothing -->
<%end%>
So this should work but the error I get is:
ArgumentError in Main#update_edit_view
Showing app/views/main/update_edit_view.erb where line #3 raised:
wrong number of arguments (0 for 1)
Extracted source (around line #3):
1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
2: <%if(params[:locid] != nil)%>
3:   <%= form.label(:name, "Location Name:") %>
4:   <%= form.text_field(:locid, :size => 40) %>
5: <%else%>
Why is it complaining about the form.label method? It works fine if I
copy paste it on the main page but in this partial one it does not work.
I assume it has got to do with not being able to find the
''form''
variable but I passed it on by using the line: :locals => { :form =>
form }
So why doesn''t it work?
-- 
Posted via http://www.ruby-forum.com/.