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\DomCrawlerCode
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));
}
}