Class: DrgcmsFormFields::HtmlField

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

Overview

Implementation of html_field DRG CMS form field.

HtmlField class only implements code for calling actual html edit field code. This is by default drg_default_html_editor gem which uses CK editor javascript plugin or any other plugin. Which plugin will be used as html editor is defined by dc_site.settings html_editor setting.

Example of dc_site.setting used for drg_default_html_editor gem.

 html_editor: ckeditor
 ck_editor:
   config_file: /files/ck_config.js  
   css_file: /files/ck_css.css
file_select: elfinder

Form example:

10:
  name: body
  type: html_field
  options: "height: 500, width: 550, toolbar: 'basic'"

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, #ro_standard, #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 html_field field html code



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/models/drgcms_form_fields/html_field.rb', line 51

def render
  #return ro_standard if @readonly  
# retrieve html editor from page settings
  editor_string = @parent.dc_get_site.params['html_editor'] if @parent.dc_get_site
  editor_string ||= 'ckeditor'
# 
  klas_string = editor_string.camelize
  if DrgcmsFormFields.const_defined?(klas_string)
    klas = DrgcmsFormFields::const_get(klas_string)
    o = klas.new(@parent, @record, @yaml).render
    @js << o.js
    @html << o.html 
  else
    @html << "HTML editor not defined. Check site.settings or include drgcms_default_html_editor gem."
  end
  self
end