Module: Bootsy::FormHelper

Defined in:
lib/bootsy/form_helper.rb

Overview

Public: Module to include Bootsy in ‘ActionView::Base`.

Instance Method Summary collapse

Instance Method Details

#bootsy_area(object_name, method, options = {}) ⇒ Object

Public: Return a textarea element with proper attributes to be loaded as a WYSIWYG editor.

object_name - The String or Symbol identifier of the object assigned

to the template.

method - The Symbol attribute name on the object assigned to the

form builder that will tailor the editor.

options - The Hash of options used to enable/disable features of

the editor (default: {}):
:container      - The `Bootsy::Container` instance model that
                  will be referenced by the editor's image
                  gallery. Defaults to the object assigned to
                  the template, if it is a `Container`.
:uploader       - The Boolean value used to enable/disable the
                  image upload feature. Default: true, if a
                  `Container` is found. false otherwise.
:editor_options - The Hash of options with Boolean values used
                  to enable/disable features of the editor.
                  Available options are described in the Bootsy
                  initializer file (which is the default for
                  this argument).


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bootsy/form_helper.rb', line 27

def bootsy_area(object_name, method, options = {})
  container = options[:container] || options[:object]

  output = self.text_area(object_name, method, text_area_options(options))

  if output.present? && enable_uploader?(options)
    container.bootsy_image_gallery_id ||= Bootsy::ImageGallery.create!.id

    output += self.render('bootsy/images/modal', container: container)

    if container.new_record?
      output += self.hidden_field(object_name, :bootsy_image_gallery_id, class: 'bootsy_image_gallery_id')
    end
  end

  output
end