Class: DrgcmsFormFields::Readonly
- Inherits:
-
DrgcmsField
- Object
- DrgcmsField
- DrgcmsFormFields::Readonly
- Defined in:
- app/models/drgcms_form_fields/readonly.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
Instance Method Summary collapse
-
#render ⇒ Object
Render readonly field html code.
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
#render ⇒ Object
Render readonly field html code
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/models/drgcms_form_fields/readonly.rb', line 54 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.send(@yaml['name'])}'") end else @parent.dc_format_value(@record.send(@yaml['name']),@yaml['format']) end @html << '</div>' self end |