Skip to content

FieldValueApplier

Writes a submitted value onto the form element that carries it.

Each control type says “this is my value” differently — an attribute for a text input, the presence of checked for a checkbox, selected on a child option for a select, and the element’s text for a textarea — so this is where knowledge of those four shapes lives.

Removing the rendered state before setting the new one is deliberate throughout: a checkbox the view rendered as checked must come back unchecked when the submission did not include it, and a value the view rendered must not survive a submission that cleared the field.

final readonly class FieldValueApplier

SourceUtil/FormPopulation/FieldValueApplier.php

public function __construct(DOMDocument $document, DocumentEncoding $encoding, string $xmlnsPrefix, bool $useCdataForTextareas, bool $includeHiddenInputs, bool $includePasswordInputs, \Closure(string, ?\DOMElement): array<int, \DOMElement> $queryElements): mixed

XPath against the document.

ParameterTypeDescription
$documentDOMDocument
$encodingDocumentEncoding
$xmlnsPrefixstring
$useCdataForTextareasbool
$includeHiddenInputsbool
$includePasswordInputsbool
$queryElements\Closure(string, ?\DOMElement): array<int, \DOMElement>XPath against the document.

Returns mixed

MethodDescription
apply(DOMElement $element, ResolvedFieldName $name, mixed $value, ParameterHolder $parameters): boolApplies the submitted value for $name to $element.

public function apply(DOMElement $element, ResolvedFieldName $name, mixed $value, ParameterHolder $parameters): bool

Applies the submitted value for $name to $element.

ParameterTypeDescription
$elementDOMElement
$nameResolvedFieldName
$valuemixed
$parametersParameterHolder

Returns bool — False when the element was left untouched, so the caller knows nothing was written for it.