Class: Nitro::Form::HasManyControl

Inherits:
Control
  • Object
show all
Defined in:
lib/nitro/helper/form/controls.rb

Overview

HasMany, ManyToMany and JoinsMany

Instance Attribute Summary

Attributes inherited from Control

#obj, #prop, #value

Instance Method Summary collapse

Methods inherited from Control

fetch, #initialize, #label, #on_populate

Methods included from XhtmlHelper

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

Constructor Details

This class inherits a constructor from Nitro::Form::Control

Instance Method Details

#renderObject

pre :do_this, :on => :populate_object



260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/nitro/helper/form/controls.rb', line 260

def render
  str = emit_container_start
  str << emit_js
  if selected_items.empty?
    str << emit_selector(:removable => false)
  else
    removable = selected_items.size != 1 ? true : false
    selected_items.each do |item|
      str << emit_selector(:selected => item.pk)
    end
  end
  str << emit_container_end
end