Textarea value should default to empty string instead of null.
This commit is contained in:
parent
76170fcf96
commit
f6725648cc
@ -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));
|
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) {
|
foreach ($this->node->childNodes as $node) {
|
||||||
$this->value .= $node->wholeText;
|
$this->value .= $node->wholeText;
|
||||||
}
|
}
|
||||||
|
@ -833,4 +833,21 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
return $dom;
|
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' => ''));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user