Sha256: cdff1789c3b75b9878af8d071a01186a2a1b7189e731f6a24038c9758c7e49b3

Contents?: true

Size: 708 Bytes

Versions: 3

Compression:

Stored size: 708 Bytes

Contents

# Tag for boolean content that is going to be rendered using checkbox
#   {{ cms:checkbox identifier }}
#
class ComfortableMexicanSofa::Content::Tag::Checkbox < ComfortableMexicanSofa::Content::Tag::Fragment

  def content
    fragment.boolean
  end

  def form_field(object_name, view, index, &block)
    name = "#{object_name}[fragments_attributes][#{index}][boolean]"
    checkbox_hidden = view.hidden_field_tag(name, "0", id: nil)
    checkbox_input  = view.check_box_tag(name, "1", self.content.present?, id: nil)

    yield [checkbox_hidden, checkbox_input].join.html_safe
  end
end

ComfortableMexicanSofa::Content::Renderer.register_tag(
  :checkbox, ComfortableMexicanSofa::Content::Tag::Checkbox
)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.2 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
comfortable_mexican_sofa-2.0.1 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
comfortable_mexican_sofa-2.0.0 lib/comfortable_mexican_sofa/content/tags/checkbox.rb