Module: DrgcmsFormFields

Defined in:
app/models/drgcms_form_fields.rb

Overview

DrgcmsFormFields module contains definitions of classes used for rendering data entry fields on DRG CMS forms.

Every data entry field type written in lowercase in form must have its class defined in CamelCase in DrgcmsFormFields module.

Each class must have at least render method implemented. All classes can inherit from DrgcmsField class which acts as abstract template class and implements most of surrounding code for creating custom DRG CMS form field.

Render method must create html and javascript code which must be saved to internal @html and @js variables. Field code is then retrived by accessing these two internal variables.

Example. How the field code is generated in form renderer:

klas_string = yaml['type'].camelize
if DrgcmsFormFields.const_defined?(klas_string) # check if field type class is defined
  klas = DrgcmsFormFields.const_get(klas_string)
  field = klas.new(self, @record, options).render
  javascript << field.js
  html << field.html 
end

Example. How to mix DRG CMS field code in Rails views:

<div>User:
<%= 
  opts = {'name' => 'user', 'eval' => "dc_choices4('dc_user','name')", 
          'html' => { 'include_blank' => true } }
  dt = DrgcmsFormFields::Select.new(self, {}, opts).render
  (dt.html + javascript_tag(dt.js)).html_safe
 %></div>

Defined Under Namespace

Classes: CheckBox, Comment, DatePicker, DateSelect, DatetimePicker, DatetimeSelect, DrgcmsField, Embedded, FileSelect, HiddenField, HtmlField, JournalDiff, LinkTo, MultitextAutocomplete, PasswordField, Readonly, Select, SubmitTag, TextArea, TextAutocomplete, TextField, TextWithSelect, TreeSelect