Class: Webrat::MultipleSelectField
- Defined in:
- lib/webrat/core/elements/field.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from Field
Attributes inherited from Element
Class Method Summary collapse
Instance Method Summary collapse
- #options ⇒ Object
- #set(value) ⇒ Object
-
#to_param ⇒ Object
We have to overide how the uri string is formed when dealing with multiples Where normally a select field might produce name=value with a multiple, we need to form something like name[]=value1&name=value2.
- #unset(value) ⇒ Object
Methods inherited from Field
#disabled?, field_class, field_classes, #id, inherited, #initialize, #label_text, load, #raise_error_if_disabled, xpath_search_excluding_hidden
Methods inherited from Element
#initialize, #inspect, load, load_all, #path
Constructor Details
This class inherits a constructor from Webrat::Field
Class Method Details
.xpath_search ⇒ Object
437 438 439 |
# File 'lib/webrat/core/elements/field.rb', line 437 def self.xpath_search [".//select[@multiple='multiple']"] end |
Instance Method Details
#options ⇒ Object
441 442 443 |
# File 'lib/webrat/core/elements/field.rb', line 441 def @options ||= SelectOption.load_all(@session, @element) end |
#set(value) ⇒ Object
445 446 447 |
# File 'lib/webrat/core/elements/field.rb', line 445 def set(value) @value << value end |
#to_param ⇒ Object
We have to overide how the uri string is formed when dealing with multiples Where normally a select field might produce name=value with a multiple, we need to form something like name[]=value1&name=value2
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/webrat/core/elements/field.rb', line 456 def to_param return nil if disabled? uri_string = @value.collect {|value| "#{name}=#{CGI.escape(value)}"}.join("&") params = case Webrat.configuration.mode when :rails parse_rails_request_params(uri_string) when :merb ::Merb::Parse.query(uri_string) else { name => @value } end unescape_params(params) end |
#unset(value) ⇒ Object
449 450 451 |
# File 'lib/webrat/core/elements/field.rb', line 449 def unset(value) @value.delete(value) end |