Class: Bureaucrat::Widgets::SelectMultiple
- Defined in:
- lib/bureaucrat/widgets.rb
Constant Summary
Constants included from Utils
Instance Attribute Summary
Attributes inherited from Select
Attributes inherited from Widget
Instance Method Summary collapse
- #has_changed?(initial, data) ⇒ Boolean
- #render(name, value, attrs = nil, choices = []) ⇒ Object
- #value_from_datahash(data, files, name) ⇒ Object
Methods inherited from Select
#initialize, #render_option, #render_options
Methods inherited from Widget
#build_attrs, #hidden?, id_for_label, inherited, #initialize, #initialize_copy, #media
Methods included from Utils
conditional_escape, escape, flatatt, format_string, make_bool, make_float, mark_safe, pretty_name, security_hash
Constructor Details
This class inherits a constructor from Bureaucrat::Widgets::Select
Instance Method Details
#has_changed?(initial, data) ⇒ Boolean
387 388 389 390 391 392 393 394 395 |
# File 'lib/bureaucrat/widgets.rb', line 387 def has_changed?(initial, data) initial = [] if initial.nil? data = [] if data.nil? return true if initial.length != data.length initial.zip(data).each do |value1, value2| return true if value1.to_s != value2.to_s end false end |
#render(name, value, attrs = nil, choices = []) ⇒ Object
368 369 370 371 372 373 374 375 376 |
# File 'lib/bureaucrat/widgets.rb', line 368 def render(name, value, attrs=nil, choices=[]) value = [] if value.nil? final_attrs = build_attrs(attrs, :name => name) output = ["<select multiple=\"multiple\"#{flatatt(final_attrs)}>"] = (choices, value) output << if && !.empty? output << '</select>' mark_safe(output.join("\n")) end |
#value_from_datahash(data, files, name) ⇒ Object
378 379 380 381 382 383 384 385 |
# File 'lib/bureaucrat/widgets.rb', line 378 def value_from_datahash(data, files, name) #if data.is_a?(MultiValueDict) || data.is_a?(MergeDict) # data.getlist(name) #else # data[name] #end data[name] end |