diff --git a/src/mechanize/form/check_box.cr b/src/mechanize/form/check_box.cr index 7de65f3..fb5b897 100644 --- a/src/mechanize/form/check_box.cr +++ b/src/mechanize/form/check_box.cr @@ -1,7 +1,7 @@ class MechanizeCr::FormContent::CheckBox < MechanizeCr::FormContent::Field property :checked - def initialize(node : Node | Myhtml::Node, value = "") + def initialize(node : Node | Myhtml::Node, value = nil) @checked = !!node["checked"] super(node, value) end @@ -22,4 +22,8 @@ class MechanizeCr::FormContent::CheckBox < MechanizeCr::FormContent::Field def click checked ? uncheck : check end + + def query_value + [@name, @value || "on"] + end end diff --git a/src/mechanize/form/field.cr b/src/mechanize/form/field.cr index be85cfe..bcff113 100644 --- a/src/mechanize/form/field.cr +++ b/src/mechanize/form/field.cr @@ -1,14 +1,14 @@ class MechanizeCr::FormContent::Field getter :node - property value : String + property value : String? getter name : String getter type : String - getter raw_value : String + getter raw_value : String? - def initialize(node : Node | Myhtml::Node, value = "") + def initialize(node : Node | Myhtml::Node, value=nil) @node = node @name = node.fetch("name", "") - @value = value || node.fetch("value", "") + @value = value || node.fetch("value", nil) @type = node.fetch("type", "") @raw_value = value end