Sha256: 6a9b5c6e2a37fd664c00a420e312cc315b84f5e8abe242052b42b8a356763beb

Contents?: true

Size: 832 Bytes

Versions: 1

Compression:

Stored size: 832 Bytes

Contents

# frozen_string_literal: true

# Tag for boolean content that is going to be rendered using checkbox
#   {{ cms:checkbox identifier }}
#
class ComfortableMediaSurfer::Content::Tags::Checkbox < ComfortableMediaSurfer::Content::Tags::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

ComfortableMediaSurfer::Content::Renderer.register_tag(
  :checkbox, ComfortableMediaSurfer::Content::Tags::Checkbox
)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comfortable_media_surfer-3.0.0 lib/comfortable_media_surfer/content/tags/checkbox.rb