Skip to content

Commit

Permalink
Fix #167: Use array_key_exists instead of isset on checking value
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jan 23, 2022
1 parent a560ad4 commit 9bf16c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Widget/Number.php
Expand Up @@ -47,7 +47,7 @@ protected function run(): string
$attributes = $this->build($this->attributes);

/** @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.number.html#input.number.attrs.value */
$value = $attributes['value'] ?? $this->getAttributeValue();
$value = array_key_exists('value', $attributes) ? $attributes['value'] : $this->getAttributeValue();
unset($attributes['value']);

if (!is_numeric($value) && null !== $value) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Widget/NumberTest.php
Expand Up @@ -196,7 +196,7 @@ public function testValue(): void

// Value `null`.
$this->assertSame(
'<input type="number" id="typeform-int" name="TypeForm[int]" value="0">',
'<input type="number" id="typeform-int" name="TypeForm[int]">',
Number::widget()->for(new TypeForm(), 'int')->value(null)->render(),
);
}
Expand Down

0 comments on commit 9bf16c4

Please sign in to comment.