From e53217e1652db90c62133ffbe27fba9e80a60a65 Mon Sep 17 00:00:00 2001 From: Nick Sagona Date: Mon, 25 Apr 2016 12:24:49 -0500 Subject: [PATCH] Patch setMarked for radio and checkbox sets --- src/Element/AbstractElement.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Element/AbstractElement.php b/src/Element/AbstractElement.php index 8769542..9386d92 100644 --- a/src/Element/AbstractElement.php +++ b/src/Element/AbstractElement.php @@ -142,11 +142,18 @@ public function setMarked($marked) $markedValues = (!is_array($marked)) ? [$marked] : $marked; foreach ($this->childNodes as $child) { - - if (in_array($child->getAttribute('value'), $markedValues)) { - $child->setAttribute('selected', 'selected'); - } else if (null !== $child->getAttribute('selected')) { - $child->removeAttribute('selected'); + if ($child->getNodeName() == 'input') { + if (in_array($child->getAttribute('value'), $markedValues)) { + $child->setAttribute('checked', 'checked'); + } else if (null !== $child->getAttribute('checked')) { + $child->removeAttribute('checked'); + } + } else { + if (in_array($child->getAttribute('value'), $markedValues)) { + $child->setAttribute('selected', 'selected'); + } else if (null !== $child->getAttribute('selected')) { + $child->removeAttribute('selected'); + } } } $this->marked = $marked;