You are here

protected function InputFormField::initialize in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Field/InputFormField.php \Symfony\Component\DomCrawler\Field\InputFormField::initialize()

Initializes the form field.

Throws

\LogicException When node type is incorrect

Overrides FormField::initialize

File

vendor/symfony/dom-crawler/Field/InputFormField.php, line 29

Class

InputFormField
InputFormField represents an input form field (an HTML input tag).

Namespace

Symfony\Component\DomCrawler\Field

Code

protected function initialize() {
  if ('input' !== $this->node->nodeName && 'button' !== $this->node->nodeName) {
    throw new \LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName));
  }
  if ('checkbox' === strtolower($this->node
    ->getAttribute('type'))) {
    throw new \LogicException('Checkboxes should be instances of ChoiceFormField.');
  }
  if ('file' === strtolower($this->node
    ->getAttribute('type'))) {
    throw new \LogicException('File inputs should be instances of FileFormField.');
  }
  $this->value = $this->node
    ->getAttribute('value');
}