Class: Cms::FormBuilder::ContentBlockFormBuilder
- Inherits:
-
SimpleForm::FormBuilder
- Object
- SimpleForm::FormBuilder
- Cms::FormBuilder::ContentBlockFormBuilder
- Includes:
- DeprecatedInputs
- Defined in:
- lib/cms/form_builder/content_block_form_builder.rb
Overview
Adds additional methods to the forms for creating content blocks.
Instance Method Summary collapse
-
#cms_attachment_manager ⇒ Object
Allows editors to add multiple files uploader for attachments.
-
#cms_error_messages ⇒ Object
Displays a concise list of error messages.
-
#cms_tag_list(options = {}) ⇒ Object
Allows editors add a space separated list of tags.
Methods included from DeprecatedInputs
#cms_drop_down, #cms_file_field, #cms_text_editor, #cms_text_field, #template_editor
Instance Method Details
#cms_attachment_manager ⇒ Object
Allows editors to add multiple files uploader for attachments. Usage:
<%= f.attachment_manager %>
Generator: The following will generate an attachments field with an associated attachment manager input.
rails generate cms:content_block Widget photos:
15 16 17 |
# File 'lib/cms/form_builder/content_block_form_builder.rb', line 15 def input :attachments, as: :attachments end |
#cms_error_messages ⇒ Object
Displays a concise list of error messages. This is may be unnecessary given that simple form will display error inline. Handles ‘global’ messages that aren’t specific to a field.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cms/form_builder/content_block_form_builder.rb', line 32 def return unless object.respond_to?(:errors) && object.errors.any? errors_list = "" errors_list << @template.content_tag(:h2, "#{object.errors.size} error prohibited this #{object_name.humanize} from being saved.".html_safe) errors_list << @template.content_tag(:p, "There were problems with the following fields:") errors_list << @template.content_tag(:ul, object.errors..map { || @template.content_tag(:li, ).html_safe }.join("\n").html_safe).html_safe @template.content_tag(:div, errors_list.html_safe, :class => "errorExplanation", :id => "errorExplanation") end |
#cms_tag_list(options = {}) ⇒ Object
Allows editors add a space separated list of tags. Each tag entered will be created if needed as an instance of a Cms::Tag.
Usage:
<%= f.cms_tag_list %>
There is no generator for this field type.
26 27 28 |
# File 'lib/cms/form_builder/content_block_form_builder.rb', line 26 def cms_tag_list(={}) input :tag_list, as: :tag_list, label: "Tags", input_html: {autocomplete: 'off'}, hint: "A space separated list of tags." end |