Skip to content
Browse files

Ouch. setValue(null) should not set element's value attribute to 'value'

  • Loading branch information...
1 parent eca7fae commit 9f8dcda1390e7a1dc77cadaec03ec994b69b96c3 @sad-spirit sad-spirit committed Apr 13, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −1 HTML/QuickForm2/Element/Input.php
  2. +8 −0 tests/QuickForm2/Element/InputTest.php
View
2 HTML/QuickForm2/Element/Input.php
@@ -84,7 +84,7 @@ public function getType()
public function setValue($value)
{
- $this->setAttribute('value', $value);
+ $this->setAttribute('value', (string)$value);
return $this;
}
View
8 tests/QuickForm2/Element/InputTest.php
@@ -94,6 +94,14 @@ public function testCanSetAndGetValue()
$this->assertNull($obj->getValue());
}
+ public function testSetNullValue()
+ {
+ $obj = new HTML_QuickForm2_Element_InputImpl();
+ $obj->setValue(null);
+
+ $this->assertEquals('', $obj->getValue());
+ }
+
public function testHtmlGeneration()
{
$obj = new HTML_QuickForm2_Element_InputImpl();

0 comments on commit 9f8dcda

Please sign in to comment.
Something went wrong with that request. Please try again.