Class: DrgcmsFormFields::DatetimeSelect

Inherits:
DrgcmsField show all
Defined in:
app/models/drgcms_form_fields.rb

Overview

Create datetime_select form field

Form options:

  • type: datetime_select (required)

  • name: Field name (required)

  • options: options which apply to date_select field (optional)

  • html: html options which apply to password field (optional)

Form example:

60:
  name: end_time
  type: datetime_select
  options:
    include_blank: true

Instance Attribute Summary

Attributes inherited from DrgcmsField

#html, #js

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DrgcmsField

#hash_to_options, #initialize, #record_text_for, #ro_standard, #set_initial_value, #set_style, #t

Constructor Details

This class inherits a constructor from DrgcmsFormFields::DrgcmsField

Class Method Details

.get_data(params, name) ⇒ Object

DatetimeSelect get_data method.



981
982
983
984
985
986
987
988
# File 'app/models/drgcms_form_fields.rb', line 981

def self.get_data(params, name)
  begin
    attrs = (1..5).map { |i| params['record']["#{name}(#{i}i)"]}
    Time.zone.local(*attrs) 
  rescue 
    nil
  end
end

Instance Method Details

#renderObject

Render datetime_select field html code



965
966
967
968
969
970
971
972
973
974
975
976
# File 'app/models/drgcms_form_fields.rb', line 965

def render
  return ro_standard( @parent.dc_format_value(@record[@yaml['name']])) if @readonly
#
  @yaml['options'] ||= {}
  set_initial_value('options','default')
  @yaml['options'].symbolize_keys!
  @yaml['html'].symbolize_keys!
#
  record = record_text_for(@yaml['name'])
  @html << @parent.datetime_select(record, @yaml['name'], @yaml['options'], @yaml['html'])
  self
end