diff --git a/src/mechanize/form.cr b/src/mechanize/form.cr index c5670fc..aebab19 100644 --- a/src/mechanize/form.cr +++ b/src/mechanize/form.cr @@ -61,7 +61,7 @@ class MechanizeCr::Form type = (html_node["type"] || "text").downcase case type when "checkbox" - @checkboxes << MechanizeCr::FormContent::CheckBox.new(html_node) + @checkboxes << MechanizeCr::FormContent::CheckBox.new(html_node, self) else @fields << MechanizeCr::FormContent::Field.new(html_node) end diff --git a/src/mechanize/form/check_box.cr b/src/mechanize/form/check_box.cr index fb5b897..c9607d6 100644 --- a/src/mechanize/form/check_box.cr +++ b/src/mechanize/form/check_box.cr @@ -1,9 +1,10 @@ class MechanizeCr::FormContent::CheckBox < MechanizeCr::FormContent::Field - property :checked + property :checked, :form - def initialize(node : Node | Myhtml::Node, value = nil) + def initialize(node : Node | Myhtml::Node, form : MechanizeCr::Form) @checked = !!node["checked"] - super(node, value) + @form = form + super(node) end def check