Class: DrgcmsFormFields::Readonly
- Inherits:
-
DrgcmsField
- Object
- DrgcmsField
- DrgcmsFormFields::Readonly
- 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
Instance Method Summary collapse
-
#render ⇒ Object
Render readonly field html code.
Methods inherited from DrgcmsField
get_data, #hash_to_options, #initialize, #record_text_for, #ro_standard, #set_initial_value, #t
Constructor Details
This class inherits a constructor from DrgcmsFormFields::DrgcmsField
Instance Method Details
#render ⇒ Object
Render readonly field html code
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'app/models/drgcms_form_fields.rb', line 231 def render @html << @parent.hidden_field('record', @yaml['name']) # retain field as hidden field @html << '<table class="dc-readonly"><td>' @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 << '</td></table>' self end |