8000 [Form] Missing Data Handling (checkbox edge cases) by filiplikavcan · Pull Request #45081 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Missing Data Handling (checkbox edge cases) #45081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: 7.4
Choose a base branch
from
8000
Prev Previous commit
Next Next commit
CS
  • Loading branch information
filiplikavcan committed Oct 4, 2022
commit 474ac3062336aabe57e3341af30dcde0a094db96
5 changes: 2 additions & 3 deletions src/Symfony/Component/Form/MissingDataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ private function handleMissingData(FormInterface $form, mixed $data): mixed
return $data;
}
}
}
catch (\Error $error) {
if ($error->getMessage() === 'Typed property Symfony\Component\Form\FormConfigBuilder::$type must not be accessed before initialization') {
} catch (\Error $error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching type errors here doesn't look like the right solution to me. We should investigate instead why the $type property in FormConfigBuilder isn't initialized at this point and fix that root issue instead.

Copy link
Contributor Author
@filiplikavcan filiplikavcan Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it either.

Another solution could be to make FormConfigBuilderInterface::getType() nullable. Then null state would have to be handled in these methods where getType() is called:

ValidatorDataCollector#getCasters
FormDataExtractor#extractConfiguration
FormDataCollector#getCasters
FormTypeCsrfExtension#finishView
FormTypeCsrfExtension#buildForm
BaseType#buildView
Button#createView

I don't know if null/undefined type is a valid case or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can look into why we run into this error here. But that will probably not happen before the weekend.

Copy link
Contributor Author
@filiplikavcan filiplikavcan Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. When I created this PR on Jan 19 it worked. These commits look related: a53b450d 488a262a

if ('Typed property Symfony\Component\Form\FormConfigBuilder::$type must not be accessed before initialization' === $error->getMessage()) {
return $data;
}

Expand Down
0