Class Cms::FormBuilder
In: app/helpers/cms/form_builder.rb
Parent: ActionView::Helpers::FormBuilder

Adds additional form fields to the Rails FormBuilder which can be used to create CMS forms.

Methods

Public Instance methods

Renders a label and checkbox suitable for allow editors to update a boolean field.

Params:

  * method - The name of the field this check_box will update.
  * options - Hash of values including:
      - :label
      - :instructions
      - :default_value
      - Any other standard FormBuilder.check_box options that will be passed directly to the check_box method.

[Source]

     # File app/helpers/cms/form_builder.rb, line 115
115:   def cms_check_box(method, options={})
116:     add_tabindex!(options)
117:     set_default_value!(method, options)
118:     cms_options = options.extract!(:label, :instructions, :default_value)
119:     render_cms_form_partial "check_box", :method=>method, :options => options, :cms_options => cms_options
120:   end

[Source]

    # File app/helpers/cms/form_builder.rb, line 55
55:   def cms_drop_down(method, choices, options={}, html_options={})
56:     add_tabindex!(html_options)
57:     set_default_value!(method, options)
58:     cms_options = options.extract!(:label, :instructions, :default_value)
59:     render_cms_form_partial :drop_down,
60:                             :object_name => @object_name, :method => method,
61:                             :choices => choices, :options => options,
62:                             :cms_options => cms_options, :html_options => html_options
63:   end

Renders instructions for a given field below the field itself. Instructions can be used to provide helpful guidance to content editors including formatting help or just explaining what a field is for.

Will not render if instructions are blank/nil.

  • instructions - The text of the instructions to show (Defaults to blank)

[Source]

     # File app/helpers/cms/form_builder.rb, line 102
102:   def cms_instructions(instructions)
103:     render_cms_form_partial :instructions, :instructions=>instructions
104:   end

[Source]

    # File app/helpers/cms/form_builder.rb, line 65
65:   def cms_tag_list(options={})
66:     add_tabindex!(options)
67:     set_default_value!(:tag_list, options)
68:     cms_options = options.extract!(:label, :instructions, :default_value)
69:     render_cms_form_partial :tag_list,
70:                             :options => options, :cms_options => cms_options
71:   end

Renders a template editor that allows developers to edit the view used to render a specific block. Render both a ‘Handler’ select box (erb, builder, etc) and a text_area for editing. Will not display the editor if the underlying object is marked as ‘render_inline(false)’. This allows developers to edit the render.html.erb directly to update how the model displays.

For example, Portlets will often specify a :template to allow runtime update of their view.

Options:

  :default_handler - Which handler will be the default when creating new instances. (Defaults to erb)
  :instructions - Instructions that will be displayed below the text area. (Blank by default)
  :label - The name for the label (Defaults to humanized version of field name)

[Source]

     # File app/helpers/cms/form_builder.rb, line 135
135:   def cms_template_editor(method, options={})
136:     if object.class.render_inline
137:       # Set some defaults
138:       @object.send("#{method}=", @object.class.default_template)
139:       options[:default_handler] = "erb" unless options[:default_handler]
140: 
141:       cms_options = options.extract!(:label, :instructions)
142:       dropdown_options = options.extract!(:default_handler)
143:       add_tabindex!(options)
144:       render_cms_form_partial :template_editor, :method=>method, :dropdown_options=>dropdown_options, :options => options, :cms_options=>cms_options
145:     end
146:   end

Renders a WYWIWYG editor with the ‘type’ selector.

[Source]

    # File app/helpers/cms/form_builder.rb, line 85
85:   def cms_text_editor(method, options = {})
86:     add_tabindex!(options)
87:     set_default_value!(method, options)
88:     cms_options = options.extract!(:label, :instructions, :default_value)
89:     render_cms_form_partial :text_editor,
90:                             :id => (options[:id] || "#{@object_name}_#{method}"),
91:                             :editor_enabled => (cookies["editorEnabled"].blank? ? true : (cookies["editorEnabled"] == 'true' || cookies["editorEnabled"] == ['true'])),
92:                             :object_name => @object_name, :method => method,
93:                             :options => options, :cms_options => cms_options
94:   end

[Source]

    # File app/helpers/cms/form_builder.rb, line 28
28:   def date_picker(method, options={})
29:     text_field(method, {:size => 10, :class => "date_picker"}.merge(options))
30:   end

Renders a CMS styled JavaScript/CSS styled select box, by itself with no label or other markup besides the js.

Options:

  * All standard select tag options plus:
  * :default_value - The default item to have selected (defaults to the value of the underlying model)
  * :width - The width for the select (defaults to 455px).

[Source]

    # File app/helpers/cms/form_builder.rb, line 14
14:   def drop_down(method, choices, options = {}, html_options = {})
15:     select_class = "#{@object_name}_#{method}"
16:     h_opts = add_tabindex!(@default_options.merge(html_options))
17:     h_opts[:class] = select_class
18: 
19:     opts = objectify_options(options)
20:     set_default_value!(method, options)
21:     cms_options = options.extract!(:default_value, :width)
22:     render_cms_form_partial :fancy_drop_down,
23:                             :object_name => @object_name, :method => method,
24:                             :choices => choices, :options => opts,
25:                             :cms_options => cms_options, :html_options => h_opts
26:   end

[Source]

    # File app/helpers/cms/form_builder.rb, line 32
32:   def tag_list(options={})
33:     field_name = options.delete(:name) || :tag_list
34:     text_field(field_name, {:size => 50, :class => "tag-list"}.merge(options))
35:   end

Renders a WYWIWYG editor without the ‘type’ selector.

[Source]

    # File app/helpers/cms/form_builder.rb, line 76
76:   def text_editor(method, options = {})
77:     @template.send(
78:             "text_editor",
79:             @object_name,
80:             method,
81:             objectify_options(options))
82:   end

[Validate]