8000 [Form] Add a form error if post_max_size has been reached. by rpg600 · Pull Request #11877 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Add a form error if post_max_size has been reached. #11877

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

Closed
wants to merge 1 commit into from
Closed

[Form] Add a form error if post_max_size has been reached. #11877

wants to merge 1 commit into from

Conversation

rpg600
Copy link
Contributor
@rpg600 rpg600 commented Sep 8, 2014
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #11729
License MIT
Doc PR n/a

This is my new PR following @lyrixx comments.

@@ -61,6 +76,10 @@ public function handleRequest(FormInterface $form, $request = null)
$params = $request->request->get($name, $default);
$files = $request->files->get($name, $default);
} else {
if ($this->serverParams->getContentLength() > $this->serverParams->getPostMaxSize()) {
$form->addError(new FormError('Max post size exceeded.'));
Copy link
Member

Choose a reason for hiding this comment

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

Please also add this string in the en translations available in the form component (and for any other language you know of course)

Copy link
Member

Choose a reason for hiding this comment

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

the form needs to be marked as submitted in this case though, so that the code can know that a submission ended up with errors rather than thinking it is not submitted (and so it is the initial display)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stof thank for your feedback, i'm agree with you but i don't know how to tackle this : if i simply set $submitted to true the web profiler don't see the form as submitted but if i submit the form, $errors is cleared.

@webmozart
Copy link
Contributor

Why are you duplicating the functionality of FormValidator here?

@stof
Copy link
Member
stof commented Sep 13, 2014

@webmozart the issue is that the FormValidator does not work well. If the post max size is reached (not the upload max size), $_POST will be empty, and so the form will not be considered submitted at all.

@webmozart
Copy link
Contributor

Thanks @rpg600! I finished your PR in #11924.

@webmozart webmozart closed this Sep 15, 2014
fabpot added a commit that referenced this pull request Sep 24, 2014
…o request handler (rpg600, webmozart)

This PR was merged into the 2.3 branch.

Discussion
----------

[Form] Moved POST_MAX_SIZE validation from FormValidator to request handler

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #11729, #11877
| License       | MIT
| Doc PR        | -

Commits
-------

759ae1a [Form] Moved POST_MAX_SIZE validation from FormValidator to request handler
4780210 [Form] Add a form error if post_max_size has been reached.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0