Skip to content

Commit

Permalink
[Fix for #703] Add cms_form_for
Browse files Browse the repository at this point in the history
* Previous solution didn't work for any view that wasn't explicitly using content_block_form_for. Added cms_form_for that should work instead (some portlets were using it)
  • Loading branch information
peakpg committed Mar 11, 2014
1 parent 1218bcc commit 00f6335
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 0 additions & 2 deletions app/controllers/cms/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module Cms
class ApplicationController < ::ApplicationController
default_form_builder = Cms::FormBuilder::ContentBlockFormBuilder
include Cms::AdminController

end
end
7 changes: 7 additions & 0 deletions app/helpers/cms/form_tag_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ def content_block_form_for(object, *args, &block)
simple_form_for(engine_aware_path(object), *(args << options.merge(builder: Cms::FormBuilder::ContentBlockFormBuilder)), &block)
end

# Simple wrapper for Rails form_for that will use the CMS CustomFormBuilder.
# Can be used by portlets or other random public facing views to render content.
def cms_form_for(*args, &block)
options = args.extract_options!
options.merge!(:builder => Cms::FormBuilder::ContentBlockFormBuilder)
form_for(*(args + [options]), &block)
end

def forecasting_a_new_section?(form_object)
Cms::Section.with_path(form_object.object.class.path).first.nil?
Expand Down
2 changes: 1 addition & 1 deletion app/views/portlets/email_page/render.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="email-page-portlet">
<%= form_for @email_message, :url => cms.portlet_handler_path(@portlet, "deliver"), :method=>'post' do |f| %>
<%= cms_form_for @email_message, :url => cms.portlet_handler_path(@portlet, "deliver"), :method=>'post' do |f| %>
<%= hidden_field_tag :email_page_portlet_url, @email_page_portlet_url %>
<%= f.cms_error_messages %>
<p>
Expand Down

0 comments on commit 00f6335

Please sign in to comment.