Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Check if the form is submitted before validation#13102

Merged
Zales0123 merged 1 commit into
Sylius:1.9from
jacquesbh:fix/form-submitted
Sep 16, 2021
Merged

Check if the form is submitted before validation#13102
Zales0123 merged 1 commit into
Sylius:1.9from
jacquesbh:fix/form-submitted

Conversation

@jacquesbh
Copy link
Copy Markdown
Contributor

@jacquesbh jacquesbh commented Sep 14, 2021

Q A
Branch? 1.10
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets
License MIT

I got this error during the development of a cart related feature:

Symfony\Component\Form\Exception\LogicException:
Cannot check if an unsubmitted form is valid. Call Form::isSubmitted() before Form::isValid().

  at vendor/symfony/form/Form.php:752
  at Symfony\Component\Form\Form->isValid()
     (vendor/sylius/sylius/src/Sylius/Bundle/OrderBundle/Controller/OrderController.php:83)
  at Sylius\Bundle\OrderBundle\Controller\OrderController->saveAction(object(Request))
     (vendor/symfony/http-kernel/HttpKernel.php:157)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:79)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:199)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:25)

This PR fixes that.

We could update all controllers with the same fix but right now I prefer to change only this one since I know the behavior.

@jacquesbh jacquesbh requested a review from a team as a code owner September 14, 2021 13:27
Copy link
Copy Markdown
Contributor

@Zales0123 Zales0123 left a comment

Choose a reason for hiding this comment

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

👍 especially, as it's consistent with what we have in ResourceController:updateAction

@Zales0123 Zales0123 added the Bug Confirmed bugs or bugfixes. label Sep 16, 2021
@Zales0123
Copy link
Copy Markdown
Contributor

The base of this pull-request was changed, you need fetch and reset your local branch
if you want to add new commits to this pull request. Reset before you pull, else commits
may become messed-up.

Unless you added new commits (to this branch) locally that you did not push yet,
execute git fetch origin && git reset "fix/form-submitted" to update your local branch.

Feel free to ask for assistance when you get stuck 👍

@Zales0123 Zales0123 changed the base branch from master to 1.9 September 16, 2021 07:20
@Zales0123 Zales0123 merged commit c00bf6d into Sylius:1.9 Sep 16, 2021
@Zales0123
Copy link
Copy Markdown
Contributor

Thanks, Jacques! 🎉

@jacquesbh jacquesbh deleted the fix/form-submitted branch September 16, 2021 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Confirmed bugs or bugfixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants