Sha256: a5ca62eba7c45732e03c548cbde59b74e50fa84d601484b892a81f106bd2ece7

Contents?: true

Size: 831 Bytes

Versions: 17

Compression:

Stored size: 831 Bytes

Contents

# frozen_string_literal: true

# 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)
    name = "#{object_name}[fragments_attributes][#{index}][boolean]"

    input = view.content_tag(:div, class: "form-check mt-2") do
      view.concat view.hidden_field_tag(name, "0", id: nil)

      options = { id: form_field_id, class: "form-check-input position-static" }
      view.concat view.check_box_tag(name, "1", content.present?, options)
    end

    yield input
  end

end

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

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
comfortable_mexican_sofa-2.0.19 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
PixelForce_ETS-0.0.2 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
PixelForce_ETS-0.0.1 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
kcyEtsTest2-0.0.4 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
kcyEtsTest2-0.0.3 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
kcyEtsTest2-0.0.2 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
kcyEtsTest2-0.0.1 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
kcyEtsTest-0.0.1 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
kcyEtsTest-2.2.19 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
ComfortableMexicanSofa-2.0.18 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
kcy1-1.0 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
comfortable_mexican_sofa-2.0.18 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
comfortable_mexican_sofa-2.0.17 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
comfortable_mexican_sofa-2.0.16 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
comfortable_mexican_sofa-2.0.15 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
comfortable_mexican_sofa-2.0.14 lib/comfortable_mexican_sofa/content/tags/checkbox.rb
comfortable_mexican_sofa-2.0.13 lib/comfortable_mexican_sofa/content/tags/checkbox.rb