add form property to checkbox

master
Kanezoh 2021-06-16 23:30:34 +09:00
parent 7d8c56e3f2
commit eec62fade2
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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