Class: DrgcmsFormFields::TextArea

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

Overview

Implementation of text_area DRG CMS form field.

Form options:

  • type: text_area (required)

  • name: Field name (required)

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

Form example:

10:
  name: css
  type: text_area
  html:
    size: 100x30

Instance Attribute Summary

Attributes inherited from DrgcmsField

#css, #js

Instance Method Summary collapse

Methods inherited from DrgcmsField

#__css_code, get_data, #hash_to_options, #html, #initialize, #record_text_for, #set_css_code, #set_default_value, #set_initial_value, #set_style, #t

Constructor Details

This class inherits a constructor from DrgcmsFormFields::DrgcmsField

Instance Method Details

#renderObject

Render text_area field html code



54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/drgcms_form_fields/text_area.rb', line 54

def render
  #return ro_standard if @readonly
  set_initial_value
#
#  @yaml['html'] ||= {}
#  value_send_as = 'p_' + @yaml['name']
#  @yaml['html']['value'] = @parent.params[value_send_as] if @parent.params[value_send_as]

  record = record_text_for(@yaml['name'])
  @html << @parent.text_area(record, @yaml['name'], @yaml['html'])
  self
end

#ro_standardObject

Return value for readonly field



45
46
47
48
49
# File 'app/models/drgcms_form_fields/text_area.rb', line 45

def ro_standard
  value = @record[@yaml['name']]
  @html << "<div class='dc-readonly'>#{value.gsub("\n",'<br>')}</div>" unless value.blank?
  self
end