I need to make a form that I can show on every page of my Refinery site. I know about
rails g refinery:form
and in fact, have already used that. I'm just wondering how to turn the generated view (located in /vendor/extensions) into a partial that I can use across the whole site.
Thanks in advance.
@IGNIS, it should just work!
Using RefineryCMS -- I have an extension at vendor/extensions/notices
.
In there is a partial app/views/custom/_displayLatestNotices.html.erb
like:
<ul id="notices">
<% Refinery::Notices::Notice.each do |notice| %>
<li><h3><%= notice.title %></h3>
<p><%= notice.body %></p>
</li>
<% end %>
</ul>
And I can show that from the main site code like:
<% content_for :body do %>
<%= render( :partial => "custom/displayLatestNotices" ) %>
<% end %>
So, in your generated form extension for "widget" you will probably have something like: app/views/refinery/widgets/widgets/new.html.erb
.
I would refactor that into two files, with the form itself in: app/views/refinery/widgets/widgets/_new_widget_form.html.erb
.
In your new.html.erb
you probably want to include this form partial -- and you should be able to include it elsewhere via:
<%= render( :partial => "refinery/widgets/widgets/_new_widget_form" ) %>
or possibly even just:
<%= render( :partial => "_new_widget_form" ) %>