Class: Occams::Content::Tag::Checkbox
- Inherits:
-
Fragment
- Object
- Occams::Content::Tag
- Fragment
- Occams::Content::Tag::Checkbox
- Defined in:
- lib/occams/content/tags/checkbox.rb
Overview
Tag for boolean content that is going to be rendered using checkbox
{{ cms:checkbox identifier }}
Instance Attribute Summary
Attributes inherited from Fragment
#identifier, #namespace, #options, #renderable
Attributes inherited from Occams::Content::Tag
Instance Method Summary collapse
Methods inherited from Fragment
#form_field_id, #fragment, #initialize, #render
Methods inherited from Occams::Content::Tag
#allow_erb?, #initialize, #nodes, #render
Constructor Details
This class inherits a constructor from Occams::Content::Tag::Fragment
Instance Method Details
#content ⇒ Object
7 8 9 |
# File 'lib/occams/content/tags/checkbox.rb', line 7 def content fragment.boolean end |
#form_field(object_name, view, index) {|input| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/occams/content/tags/checkbox.rb', line 11 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) = { id: form_field_id, class: 'form-check-input position-static' } view.concat view.check_box_tag(name, '1', content.present?, ) end yield input end |