My layout file is like this…
If you notice, ive mentioned that some form elements are rendered in
the “sidebox” divs. If instead i yield them in the “content” div
alongwith the rest of the form, everything works fine.
I figured maybe its because all the fields do not fall between the
form_for and end tags. So i tried something like this
/views/projects/new.html.erb
<% form_for @project do |f| %>
<%= f.error_messages %>
<% content_for :formfields do%>
<%=render :partial => “project”, :locals => {:f => f}%>
<%= f.submit “Save as Draft” %>
<% end %>
<% end %>
/views/layouts/application.html.erb
<%= controller.controller_name.capitalize %>
<div class="content">
<% flash.each do |key, msg| %>
<%= content_tag :p, msg, :id => key, :class => 'flash'
%>
<% end %>
<%= yield :formfields%>
<div class="sidebar">
<div class="sidebox">
<%= yield :sidebox1 %>
</div>
<div class="sidebox">
<%= yield :sidebox2 %>
</div>
<div class="sidebox">
<%= yield :sidebox3 %>
</div>
</div>
<div style="clear:both;"></div>
views/projects/_project.html.erb
…
…
<% content_for :sidebox1 do%>
…
…
<% end %>
<% content_for :sidebox2 do%>
…
…
<% end %>
<% content_for :sidebox3 do%>
…
…
<% end %># “…” representing form fields.
This way, the form fields are yielded into a div “content” which is
part of a larger div “wrapper” that yields the rest of the content
(including the form_for and end tags) (did this only for testing, do
not plan to structure my page this way). In any case, that did not
work either. The “Submit” button did nothing. The form was rendered
but clicking the Submit button did not submit anything.
Any suggestions?