Skip to content
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

Expected argument of type "int", "null" given at property path "qty". #80

Open
RickVdrongelen opened this issue Apr 8, 2024 · 2 comments · May be fixed by #81
Open

Expected argument of type "int", "null" given at property path "qty". #80

RickVdrongelen opened this issue Apr 8, 2024 · 2 comments · May be fixed by #81

Comments

@RickVdrongelen
Copy link

I discovered an issue when i tried saving an empty row. I expected it to have the same behaviour as delete_empty would have, but instead the plugin tried to save the empty row. Which throwed an exception because null is not a NumberType. I tried to add the delete_empty => true to the collection type, but this did not have any effect. I added a suggestion to fix this, but of course any other fix is also very welcome. I am not able to provide a PR due to time constraints.

How to reproduce issue

  • Add 1 or more valid tierprice to any product variant
  • Add a empty row to tierprices
  • Save tierpricing
    Then the following error is shown:
    Expected argument of type "int", "null" given at property path "qty".

Suggested fix / workaround

Add empty_data => 0 to both the qty and price types in the TierPriceType

@mamazu
Copy link
Collaborator

mamazu commented Apr 12, 2024

Thanks for the error report.

The problem in this case is that the Symfony form produces bad values that the entity doesn't allow. I think one way to fix this is to make everything in the entity nullable (like Sylius does by default as well). However this makes the code rather hard to use with correct typing as the null value is only possible until the entity is validated. Another option would be to create a custom data mapper.

I'll try to make a PR and see how it goes.

@mamazu mamazu linked a pull request Apr 24, 2024 that will close this issue
@mamazu
Copy link
Collaborator

mamazu commented Apr 24, 2024

I have made a pull request could you try this out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants