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

Breadcrumb

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

function FormFieldRegistry::set

Set the value of a field based on the fully qualified name and its children.

Throws

\InvalidArgumentException if the field does not exist

File

vendor/symfony/dom-crawler/FormFieldRegistry.php, line 106

Class

FormFieldRegistry
This is an internal class that must not be used directly.

Namespace

Symfony\Component\DomCrawler

Code

public function set(string $name, mixed $value) : void {
    $target =& $this->get($name);
    if (!\is_array($value) && $target instanceof FormField || $target instanceof Field\ChoiceFormField) {
        $target->setValue($value);
    }
    elseif (\is_array($value)) {
        $registry = new static();
        $registry->base = $name;
        $registry->fields = $value;
        foreach ($registry->all() as $k => $v) {
            $this->set($k, $v);
        }
    }
    else {
        throw new \InvalidArgumentException(\sprintf('Cannot set value on a compound field "%s".', $name));
    }
}

API Navigation

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