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
26 changes: 16 additions & 10 deletions src/Form/Manipulator/DoctrineORMManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,27 @@ public function __construct(DoctrineORMInfo $doctrineORMInfo, array $globalExclu

public function getFieldsConfig(FormInterface $form): array
{
$class = $this->getDataClass($form);
$formOptions = $form->getConfig()->getOptions();

// Filtering to remove excludedFields
$objectFieldsConfig = $this->doctrineORMInfo->getFieldsConfig($class);
$validObjectFieldsConfig = $this->filteringValidObjectFields($objectFieldsConfig, $formOptions['excluded_fields']);

if (empty($formOptions['fields'])) {
return $validObjectFieldsConfig;
if (array_key_exists('mapped', $formOptions) && false !== $formOptions) {
$class = null;
$validObjectFieldsConfig = [];
} else {
$class = $this->getDataClass($form);

// Filtering to remove excludedFields
$objectFieldsConfig = $this->doctrineORMInfo->getFieldsConfig($class);
$validObjectFieldsConfig = $this->filteringValidObjectFields($objectFieldsConfig, $formOptions['excluded_fields']);

if (empty($formOptions['fields'])) {
return $validObjectFieldsConfig;
}
}

$fields = [];

foreach ($formOptions['fields'] as $formFieldName => $formFieldConfig) {
$this->checkFieldIsValid($formFieldName, $formFieldConfig, $validObjectFieldsConfig, $class);
if ($class) {
$this->checkFieldIsValid($formFieldName, $formFieldConfig, $validObjectFieldsConfig, $class);
}

if (null === $formFieldConfig) {
continue;
Expand Down
8 changes: 0 additions & 8 deletions src/Form/Type/AutoFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,5 @@ public function configureOptions(OptionsResolver $resolver): void
'fields' => [],
'excluded_fields' => [],
]);

$resolver->setNormalizer('data_class', function (Options $options, $value): string {
if (empty($value)) {
throw new \RuntimeException('Missing "data_class" option of "AutoFormType".');
}

return $value;
});
}
}