Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions core/Form/Form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,19 +427,13 @@ private function importPrimitive($scope, BasePrimitive $prm)
**/
private function checkImportResult(BasePrimitive $prm, $result)
{
if (
$prm instanceof PrimitiveAlias
&& $result !== null
)
$this->markGood($prm->getInner()->getName());

$name = $prm->getName();

if (null === $result) {
if ($result === null) {
if ($prm->isRequired())
$this->errors[$name] = self::MISSING;

} elseif (true === $result) {
} elseif ($result === true) {
unset($this->errors[$name]);

} elseif ($error = $prm->getCustomError()) {
Expand All @@ -448,6 +442,14 @@ private function checkImportResult(BasePrimitive $prm, $result)

} else
$this->errors[$name] = self::WRONG;

if (
$prm instanceof PrimitiveAlias
&& $this->primitiveExists($prm->getInner()->getName())
&& $result === true
) {
unset($this->errors[$prm->getInner()->getName()]);
}

return $this;
}
Expand Down
6 changes: 6 additions & 0 deletions core/Form/FormUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ final class FormUtils extends StaticFactory
foreach ($form->getPrimitiveList() as $name => $prm) {
if (isset($list[$name])) {
$proto->exportPrimitive($name, $prm, $object, $ignoreNull);

} elseif (
$prm instanceof PrimitiveAlias
&& isset($list[$prm->getInner()->getName()])
) {
$proto->exportPrimitive($prm->getInner()->getName(), $prm->getInner(), $object, $ignoreNull);
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/Form/PlainForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function add(BasePrimitive $prm)

Assert::isFalse(
isset($this->primitives[$name]),
'i am already exists!'
'primitive name "'.$name.'" already exists!'
);

$this->primitives[$name] = $prm;
Expand Down