You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
I noticed, that my form was not validating correctly. After some digging in code, I found, that although inputSpec is properly set in ElementAnnotationsListener::handleComposedObjectAnnotation, it gets ignored in AnnotationBuilder::configureElement
So here is what I found was causing it, and how I fixed it (although I am not sure, if that is correct):
AnnotationBulder.php:
protectedfunctionconfigureElement($annotations, $reflection, $formSpec, $filterSpec)
{
// If the element is marked as exclude, return earlyif ($this->checkForExclude($annotations)) {
return;
}
$events = $this->getEventManager();
$name = $this->discoverName($annotations, $reflection);
$elementSpec = newArrayObject([
'flags' => [],
'spec' => [
'name' => $name
],
]);
$inputSpec = newArrayObject([
'name' => $name,
]);
$params = [
'name' => $name,
'elementSpec' => $elementSpec,
'inputSpec' => $inputSpec, // Before the fix, this would not change its vallue'formSpec' => $formSpec,
'filterSpec' => $filterSpec,
];
foreach ($annotationsas$annotation) {
$params['annotation'] = $annotation;
// -> This causes ElementAnnotationsListener::handleComposedObjectAnnotation to configure the element$events->trigger(__FUNCTION__, $this, $params);
}
// Rest of the code is omitted (not relevant)
}
ElementAnnotationsListener.php:
publicfunctionhandleComposedObjectAnnotation($e)
{
$annotation = $e->getParam('annotation');
if (!$annotation instanceof ComposedObject) {
return;
}
$class = $annotation->getComposedObject();
$annotationManager = $e->getTarget();
$specification = $annotationManager->getFormSpecification($class);
$name = $e->getParam('name');
$elementSpec = $e->getParam('elementSpec');
if ($annotation->isCollection()) {
// Omitted, not relevant
} else {
// Compose input filter into parent input filter$inputFilter = $specification['input_filter'];
if (!isset($inputFilter['type'])) {
$inputFilter['type'] = 'Zend\InputFilter\InputFilter';
}
// So here is what causes the problem:// For some reason setting inputSpec like this causes it to be ignored in AnnotationBuilder::configureElement// $e->setParam('inputSpec', $inputFilter);// This seems to work, now the composed object receives the correct inputSpec/** @var ArrayObject $inputSpec */$inputSpec = $e->getParam('inputSpec');
$inputSpec->exchangeArray($inputFilter);
unset($specification['input_filter']);
// Rest of the code is omitted, not relevant
}
}
I don't believe that this is expected behavior, because every other aspect of the element configuration can be set in ElementAnnotationsListener::handleComposedObjectAnnotation.
The text was updated successfully, but these errors were encountered:
I noticed, that my form was not validating correctly. After some digging in code, I found, that although inputSpec is properly set in ElementAnnotationsListener::handleComposedObjectAnnotation, it gets ignored in AnnotationBuilder::configureElement
So here is what I found was causing it, and how I fixed it (although I am not sure, if that is correct):
AnnotationBulder.php:
ElementAnnotationsListener.php:
I don't believe that this is expected behavior, because every other aspect of the element configuration can be set in ElementAnnotationsListener::handleComposedObjectAnnotation.
The text was updated successfully, but these errors were encountered: