Textarea value should default to empty string instead of null.

This commit is contained in:
Sascha Grossenbacher 2014-04-17 15:51:13 +02:00 committed by Fabien Potencier
parent 76170fcf96
commit f6725648cc
2 changed files with 18 additions and 1 deletions

View File

@ -31,7 +31,7 @@ class TextareaFormField extends FormField
throw new \LogicException(sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $this->node->nodeName));
}
$this->value = null;
$this->value = '';
foreach ($this->node->childNodes as $node) {
$this->value .= $node->wholeText;
}

View File

@ -833,4 +833,21 @@ class FormTest extends \PHPUnit_Framework_TestCase
return $dom;
}
public function testgetPhpValuesWithEmptyTextarea()
{
$dom = new \DOMDocument();
$dom->loadHTML('
<html>
<form>
<textarea name="example"></textarea>
</form>
</html>
');
$nodes = $dom->getElementsByTagName('form');
$form = new Form($nodes->item(0), 'http://example.com');
$this->assertEquals($form->getPhpValues(), array('example' => ''));
}
}