Object
This class represents a field in a form. It handles the following input tags found in a form:
text
password
hidden
int
textarea
keygen
To set the value of a field, just use the value method:
field.value = "foo"
# File lib/mechanize/form/field.rb, line 25 def initialize node, value = node['value'] @node = node @name = Mechanize::Util.html_unescape(node['name']) @raw_value = value @value = if value.is_a? String Mechanize::Util.html_unescape(value) else value end @type = node['type'] end
# File lib/mechanize/form/field.rb, line 42 def <=> other return 0 if self == other # If both are hashes, sort by index if Hash === node && Hash === other.node && index return index <=> other.index end # Otherwise put Hash based fields at the end return 1 if Hash === node return -1 if Hash === other.node # Finally let nokogiri determine sort order node <=> other.node end
This method is a shortcut to get field's DOM class. Common usage: form.field_with(:dom_class => "foo")
# File lib/mechanize/form/field.rb, line 66 def dom_class node['class'] end
This method is a shortcut to get field's DOM id. Common usage: form.field_with(:dom_id => "foo")
# File lib/mechanize/form/field.rb, line 60 def dom_id node['id'] end
Generated with the Darkfish Rdoc Generator 2.