// new entries, which were added by the data mapper. The data mapper ignores existing
// entries, so we need to manually unset removed entries in the collection.
if (!\
is_array($data) && !
($data instanceof \Traversable &&
$data instanceof \ArrayAccess
)) { throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)'
);
} if ($this->deleteEmpty
) { $previousData =
$form->
getData();
/** @var FormInterface $child */
foreach ($form as $name =>
$child) { if (!
$child->
isValid() || !
$child->
isSynchronized()) { continue;
} $isNew = !
isset($previousData[$name]);
$isEmpty = \
is_callable($this->deleteEmpty
) ?
($this->deleteEmpty
)($child->
getData()) :
$child->
isEmpty();
// $isNew can only be true if allowAdd is true, so we don't
// need to check allowAdd again
if ($isEmpty && ($isNew ||
$this->allowDelete
)) { unset($data[$name]);
$form->
remove($name);
}