Class: DrgcmsFormFields::LinkTo
- Inherits:
-
DrgcmsField
- Object
- DrgcmsField
- DrgcmsFormFields::LinkTo
- Defined in:
- app/models/drgcms_form_fields.rb
Overview
Implementation of link_to DRG CMS form field. link_to form field is mostly used by polls but can be also incorporated anywhere on the form.
Form options:
-
type:
link_to (required) -
caption:
Link caption -
icon:
Link icon -
url:
direct url link -
controller:
controller name -
action:
action name -
html:
html options which apply to link_to (optional)
Form example:
30:
type: link_to
caption: Some action
icon: cogs
controller: my_controller
action: my_action
id: id # will be replaced by record._id
Instance Attribute Summary
Attributes inherited from DrgcmsField
Instance Method Summary collapse
-
#render ⇒ Object
Render link_to 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 link_to field html code
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
# File 'app/models/drgcms_form_fields.rb', line 812 def render @yaml['html'] ||= {} @yaml['html']['class'] ||= 'dc-link dc-animate' @yaml['html'].symbolize_keys! # @yaml[:id] = record._id if @yaml[:id] == 'id' url = @yaml['url'] || "#{@yaml[:controller]}/#{@yaml[:action]}/#{@yaml[:id]}" url.gsub!('//','/') # no action and id url = '/' + @yaml['url'] unless url[0,1] == '/' # no leading / url.chop if url[0,-1] == '/' # remove trailing / # = @yaml['caption'] || @yaml['text'] @html << @parent.dc_link_to(, @yaml['icon'], url, @yaml['html']) self end |