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 19 19: def initialize node, value = node['value'] 20: @node = node 21: @name = Mechanize::Util.html_unescape(node['name']) 22: @value = if value.is_a? String 23: Mechanize::Util.html_unescape(value) 24: else 25: value 26: end 27: 28: @type = node['type'] 29: end
# File lib/mechanize/form/field.rb, line 35 35: def <=> other 36: return 0 if self == other 37: return 1 if Hash === node 38: return 1 if Hash === other.node 39: node <=> other.node 40: end
This method is a shortcut to get field’s DOM id. Common usage: form.field_with(:dom_class => “foo”)
# File lib/mechanize/form/field.rb, line 50 50: def dom_class 51: node['class'] 52: 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 44 44: def dom_id 45: node['id'] 46: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.