Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dcvezzani/5320204 to your computer and use it in GitHub Desktop.
Save dcvezzani/5320204 to your computer and use it in GitHub Desktop.
Adds rich text editor (rich text only, no plain text option) form helper.
# rails-app/browsercms/app/helpers/cms/form_builder.rb
#
# Adds additional form fields to the Rails FormBuilder which can be used to create CMS forms.
#
class Cms::FormBuilder < ActionView::Helpers::FormBuilder
...
# Renders a WYWIWYG rich text editor.
def cms_richtext_editor(method, options = {})
add_tabindex!(options)
set_default_value!(method, options)
cms_options = options.extract_only!(:label, :instructions, :default_value)
render_cms_form_partial :richtext_editor,
:id => (options[:id] || "#{@object_name}_#{method}"),
:editor_enabled => (cookies["editorEnabled"].blank? ? true : (cookies["editorEnabled"] == 'true' || cookies["editorEnabled"] == ['true'])),
:object_name => @object_name, :method => method,
:options => options, :cms_options => cms_options
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment