Class: ComfortableMexicanSofa::Content::Tag::Datetime

Inherits:
Fragment show all
Defined in:
lib/comfortable_mexican_sofa/content/tags/datetime.rb

Overview

Tag for text content that is going to be rendered using text input with datetime widget

{{ cms:datetime identifier }}

Instance Attribute Summary

Attributes inherited from Fragment

#identifier, #namespace, #options, #renderable

Attributes inherited from ComfortableMexicanSofa::Content::Tag

#context, #params

Instance Method Summary collapse

Methods inherited from Fragment

#fragment, #initialize, #render

Methods inherited from ComfortableMexicanSofa::Content::Tag

#allow_erb, #initialize, #nodes, #parse_params_string, #render

Constructor Details

This class inherits a constructor from ComfortableMexicanSofa::Content::Tag::Fragment

Instance Method Details

#contentObject



6
7
8
# File 'lib/comfortable_mexican_sofa/content/tags/datetime.rb', line 6

def content
  fragment.datetime
end

#form_field(object_name, view, index) {|input| ... } ⇒ Object

Yields:

  • (input)


10
11
12
13
14
15
16
17
# File 'lib/comfortable_mexican_sofa/content/tags/datetime.rb', line 10

def form_field(object_name, view, index, &block)
  name    = "#{object_name}[fragments_attributes][#{index}][datetime]"
  options = {id: nil, class: "form-control", data: {"cms-datetime" => true}}
  value   = self.content.present?? self.content.to_s(:db) : ""
  input   = view.send(:text_field_tag, name, value, options)

  yield input
end