TextareaFormField.php 979 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. class TextareaFormField extends FormField
  17. {
  18. /**
  19. * Initializes the form field.
  20. *
  21. * @throws \LogicException When node type is incorrect
  22. */
  23. protected function initialize()
  24. {
  25. if ('textarea' !== $this->node->nodeName) {
  26. throw new \LogicException(sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $this->node->nodeName));
  27. }
  28. $this->value = '';
  29. foreach ($this->node->childNodes as $node) {
  30. $this->value .= $node->wholeText;
  31. }
  32. }
  33. }