Class: DrgcmsFormFields::CheckBox
- Inherits:
-
DrgcmsField
- Object
- DrgcmsField
- DrgcmsFormFields::CheckBox
- Defined in:
- app/models/drgcms_form_fields.rb
Overview
Implementation of check_box DRG CMS form field.
Form options:
-
name:
field name (required) -
type:
check_box (required) -
choices:
Values check_box separated by comma (1,0) (yes,no) -
checked_value:
1 or yes or approved -
unchecked_value:
0 or no or not approved -
html:
html options which apply to check_box field (optional)
Form example:
30:
name: active
type: check_box
40:
name: status
type: check_box
choices: yes,no
Instance Attribute Summary
Attributes inherited from DrgcmsField
Instance Method Summary collapse
-
#render ⇒ Object
Render check_box field html code.
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
#render ⇒ Object
Render check_box field html code
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
# File 'app/models/drgcms_form_fields.rb', line 741 def render set_initial_value('html','default') # checked flag must be set @yaml['html']['checked'] = !@parent.dc_dont?(@yaml['html']['default']) if @yaml['html']['default'] # disable it if readonly @yaml['html']['disabled'] = @readonly ? true : nil # If choices are present split them to set checked and unchecked value @yaml['checked_value'], @yaml['unchecked_value'] = @yaml['choices'].split(',') if @yaml['choices'] @yaml['html'].symbolize_keys! record = record_text_for(@yaml['name']) @html << if @yaml['checked_value'] @parent.check_box(record, @yaml['name'], @yaml['html'], @yaml['checked_value'], @yaml['unchecked_value'] || '0') else @parent.check_box(record, @yaml['name'], @yaml['html']) end self end |