TextareaFormField.php 1006 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DomCrawler\Field;
  11. /**
  12. * TextareaFormField represents a textarea form field (an HTML textarea tag).
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. *
  16. * @api
  17. */
  18. class TextareaFormField extends FormField
  19. {
  20. /**
  21. * Initializes the form field.
  22. *
  23. * @throws \LogicException When node type is incorrect
  24. */
  25. protected function initialize()
  26. {
  27. if ('textarea' != $this->node->nodeName) {
  28. throw new \LogicException(sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $this->node->nodeName));
  29. }
  30. $this->value = null;
  31. foreach ($this->node->childNodes as $node) {
  32. $this->value .= $this->document->saveXML($node);
  33. }
  34. }
  35. }