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

Skip to content

[RFC][Form] a fully disabled form should not pass isValid() #27217

Open
@dkarlovi

Description

@dkarlovi

Symfony version(s) affected: 4.0

Description
I'm implementing a brute force protection for my login/register etc. forms. I have a "soft threshold" (CAPTCHA needed) and a "hard threshold" (no further interaction is allowed).

To achieve the latter, I've set disabled: true on the form itself. This works as I'd have expect, fully disabling the form for user interaction while rendered in the browser.

What I did not expect was that now, since there are no types being considered, the form suddenly becomes valid and passes any validations, it even claims it's been submitted (but this shouldn't even be possible with a fully disabled form).

It seems to me disabling the root form object should mean it's not considered submitted / valid.

How to reproduce

Create a form with a validator, submit to confirm it fails. Now change to disabled: true and submit again. Now it suddenly passes validation even though the form is disabled and shouldn't work at all.

Possible Solution
Perhaps isSubmitted(): false if disabled: true?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions