8000 [DomCrawler] Make `ChoiceFormField::isDisabled` return `true` for unc… · symfony/symfony@9807ce6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9807ce6

Browse files
committed
[DomCrawler] Make ChoiceFormField::isDisabled return true for unchecked disabled checkboxes
1 parent f63d644 commit 9807ce6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public function hasValue(): bool
4545
*/
4646
public function isDisabled(): bool
4747
{
48+
if ('checkbox' === $this->type) {
49+
return parent::isDisabled();
50+
}
51+
4852
if (parent::isDisabled() && 'select' === $this->type) {
4953
return true;
5054
}

src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,17 @@ public function testCheckboxWithEmptyBooleanAttribute()
272272
$this->assertEquals('foo', $field->getValue());
273273
}
274274

275+
public function testCheckboxIsDisabled()
276+
{
277+
$node = $this->createNode('input', '', ['type' => 'checkbox', 'name' => 'name', 'disabled' => '']);
278+
$field = new ChoiceFormField($node);
279+
280+
$this->assertTrue($field->isDisabled(), '->isDisabled() returns true when the checkbox is disabled, even if it is not checked');
281+
282+
$field->tick();
283+
$this->assertTrue($field->isDisabled(), '->isDisabled() returns true when the checkbox is disabled, even if it is checked');
284+
}
285+
275286
public function testTick()
276287
{
277288
$node = $this->createSelectNode(['foo' => false, 'bar' => false]);

0 commit comments

Comments
 (0)
0