Class: DrgcmsFormFields::Readonly

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

Overview

Implementation of readonly DRG CMS form field.

Readonly field value is just painted on form.

Form options:

  • name: field name

  • type: readonly

  • eval: value will be provided by evaluating expression. Usually dc_name4_id helper

can be used to get value. Example: dc_name4_id,model_name_in_lower_case,field_name

  • readonly: yes (can be applied to any field type)

Form example:

10:
  name: user
  type: readonly
  html:
    size: 50
20:
  name: created_by
  type: readonly
  eval: dc_name4_id,dc_user,name

Instance Attribute Summary

Attributes inherited from DrgcmsField

#html, #js

Instance Method Summary collapse

Methods inherited from DrgcmsField

get_data, #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

Instance Method Details

#renderObject

Render readonly field html code



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'app/models/drgcms_form_fields.rb', line 262

def render 
  @html << @parent.hidden_field('record', @yaml['name']) # retain field as hidden field
  @html << '<div class="dc-readonly">'
  
  @html << if @yaml['eval']
    if @yaml['eval'].match('dc_name4_id')
      a = @yaml['eval'].split(',')
      if a.size == 3
        @parent.dc_name4_id(a[1], a[2], nil, @record[ @yaml['name'] ])
      else
        @parent.dc_name4_id(a[1], a[2], a[3], @record[ @yaml['name'] ])
      end
      
#      @parent.dc_name4_id(a[1], a[2], @record[ @yaml['name'] ])
    else
      eval( "#{@yaml['eval']} '#{@record[ @yaml['name'] ]}'") 
    end
  else
    @parent.dc_format_value(@record[@yaml['name']],@yaml['format'])    
  end  
  @html << '</div>'
  self
end