Class: Nitro::RefersToControl

Inherits:
RelationControl show all
Defined in:
lib/nitro/control/relation/refers_to.rb

Overview

RefersTo. Also used for BelongsTo.

Instance Attribute Summary

Attributes inherited from AttributeControl

#anno, #attribute, #value

Attributes included from ElementMixin

#_children, #_parent, #_text, #_view, #id

Instance Method Summary collapse

Methods inherited from RelationControl

#initialize, #rel, #symbol

Methods inherited from AttributeControl

#initialize

Methods included from XhtmlHelper

#date_select, #datetime_select, #hidden, #href_of, #js_popup, #link_to, #objects_to_options, #onclick_popup, #options, #popup, #submit, #time_select

Methods inherited from Element

compile_template_elements

Methods included from ElementMixin

#add_child, #close, #content, #initialize, #open, #render_children

Constructor Details

This class inherits a constructor from Nitro::RelationControl

Instance Method Details

#emit_optionsObject



18
19
20
21
22
23
24
25
# File 'lib/nitro/control/relation/refers_to.rb', line 18

def emit_options
  objs = rel.target_class.all
  selected = selected.pk if selected = value
  %{
    <option value="">--</option>
    #{options(:labels => objs.map{|o| o.to_s}, :values => objs.map{|o| o.pk}, :selected => selected)}
  }
end

#renderObject



9
10
11
12
13
14
15
16
# File 'lib/nitro/control/relation/refers_to.rb', line 9

def render
  %{
  #{emit_label}
  <select id="#{rel.name}_ctl" name="#{rel.name}"#{emit_disabled}>
  #{emit_options}
  </select>
  }
end