Class: Bureaucrat::Widgets::MultipleHiddenInput
- Inherits:
-
HiddenInput
- Object
- Widget
- Input
- HiddenInput
- Bureaucrat::Widgets::MultipleHiddenInput
- Defined in:
- lib/bureaucrat/widgets.rb
Constant Summary
Constants included from Utils
Instance Attribute Summary collapse
-
#choices ⇒ Object
Used by choice fields.
Attributes inherited from Widget
Instance Method Summary collapse
-
#initialize(attrs = nil, choices = []) ⇒ MultipleHiddenInput
constructor
A new instance of MultipleHiddenInput.
- #render(name, value, attrs = nil, choices = []) ⇒ Object
- #value_from_datahash(data, files, name) ⇒ Object
Methods inherited from Input
Methods inherited from Widget
#build_attrs, #has_changed?, #hidden?, id_for_label, inherited, #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
#initialize(attrs = nil, choices = []) ⇒ MultipleHiddenInput
Returns a new instance of MultipleHiddenInput.
209 210 211 212 213 |
# File 'lib/bureaucrat/widgets.rb', line 209 def initialize(attrs=nil, choices=[]) super(attrs) # choices can be any enumerable @choices = choices end |
Instance Attribute Details
#choices ⇒ Object
Used by choice fields
207 208 209 |
# File 'lib/bureaucrat/widgets.rb', line 207 def choices @choices end |
Instance Method Details
#render(name, value, attrs = nil, choices = []) ⇒ Object
215 216 217 218 219 220 221 222 223 |
# File 'lib/bureaucrat/widgets.rb', line 215 def render(name, value, attrs=nil, choices=[]) value ||= [] final_attrs = build_attrs(attrs, :type => self.class.input_type, :name => name) mark_safe(value.map do |v| rattrs = {:value => v.to_s}.merge(final_attrs) "<input#{flatatt(rattrs)} />" end.join("\n")) end |
#value_from_datahash(data, files, name) ⇒ Object
225 226 227 228 229 230 231 232 |
# File 'lib/bureaucrat/widgets.rb', line 225 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 |