Class: Bureaucrat::Widgets::RadioSelect
- Defined in:
- lib/bureaucrat/widgets.rb
Constant Summary
Constants included from Utils
Instance Attribute Summary
Attributes inherited from Select
Attributes inherited from Widget
Class Method Summary collapse
Instance Method Summary collapse
- #get_renderer(name, value, attrs = nil, choices = []) ⇒ Object
-
#initialize(*args) ⇒ RadioSelect
constructor
A new instance of RadioSelect.
- #render(name, value, attrs = nil, choices = []) ⇒ Object
- #renderer ⇒ Object
Methods inherited from Select
#render_option, #render_options
Methods inherited from Widget
#build_attrs, #has_changed?, #hidden?, #initialize_copy, #needs_multipart?, #value_from_formdata
Methods included from Utils
#blank_value?, #conditional_escape, #escape, #flatatt, #format_string, #make_bool, #make_float, #mark_safe, #pretty_name
Constructor Details
#initialize(*args) ⇒ RadioSelect
Returns a new instance of RadioSelect.
494 495 496 497 498 |
# File 'lib/bureaucrat/widgets.rb', line 494 def initialize(*args) = args.last.is_a?(Hash) ? args.last : {} @renderer = .fetch(:renderer, renderer) super end |
Class Method Details
.id_for_label(id_) ⇒ Object
486 487 488 |
# File 'lib/bureaucrat/widgets.rb', line 486 def self.id_for_label(id_) id_.empty? ? id_ : id_ + '_0' end |
Instance Method Details
#get_renderer(name, value, attrs = nil, choices = []) ⇒ Object
500 501 502 503 504 505 506 |
# File 'lib/bureaucrat/widgets.rb', line 500 def get_renderer(name, value, attrs=nil, choices=[]) value ||= '' str_value = value.to_s final_attrs = build_attrs(attrs) choices = @choices.to_a + choices.to_a @renderer.new(name, str_value, final_attrs, choices) end |
#render(name, value, attrs = nil, choices = []) ⇒ Object
508 509 510 |
# File 'lib/bureaucrat/widgets.rb', line 508 def render(name, value, attrs=nil, choices=[]) get_renderer(name, value, attrs, choices).render end |
#renderer ⇒ Object
490 491 492 |
# File 'lib/bureaucrat/widgets.rb', line 490 def renderer RadioFieldRenderer end |