diff --git a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php index 794e966ac6..987b78b5c7 100644 --- a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php @@ -33,7 +33,7 @@ class TextareaFormField extends FormField $this->value = null; foreach ($this->node->childNodes as $node) { - $this->value .= $this->document->saveXML($node); + $this->value .= $node->wholeText; } } } diff --git a/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php b/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php index a33c44f230..5df2e77b81 100644 --- a/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php @@ -29,5 +29,19 @@ class TextareaFormFieldTest extends FormFieldTestCase } catch (\LogicException $e) { $this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a textarea'); } + + // Ensure that valid HTML can be used on a textarea. + $node = $this->createNode('textarea', 'foo bar