Skip to content

[Form][Validation] Validation readonly and disabled forms #12799

@peterrehm

Description

@peterrehm

As per specification the validation must be skipped for disabled types (http://www.w3.org/TR/html5/forms.html#concept-fe-disabled).

Strange is somehow that the validation must be skipped also for readonly fields.
(http://www.w3.org/TR/html5/forms.html#the-readonly-attribute) This is currently
not reflected in the Symfony implementation and makes imho also not much sense.

Currently readonly fields are validated hence it can happen that the readonly attribute
is changed on the client side which makes sense, in theory the values could be altered
as well.

Also I found out if you have a disabled element in your form it is not validated. If however
an constraint in another form element fails the errors of the disabled form type will be shown.
If no other constraint fails the error will not be shown.

@webmozart What do you think about an "real" read_only field which behaves as "disabled" with the difference that it will be validated rather than deprecating it? I think this is the common behavior users expect when using read_only and we could teach it accordingly.

Also is it intended that errors to a disabled form element will be shown in case another constraint fails?

I think I would have a look at it if you let me know your thoughts.

Relates to #10658

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