Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. InputFormField.php

function 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() : void {
    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));
    }
    $type = strtolower($this->node
        ->getAttribute('type'));
    if ('checkbox' === $type) {
        throw new \LogicException('Checkboxes should be instances of ChoiceFormField.');
    }
    if ('file' === $type) {
        throw new \LogicException('File inputs should be instances of FileFormField.');
    }
    $this->value = $this->node
        ->getAttribute('value');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal