Skip to content

Apply ng-submitted class to formGroups that have been submitted #30486

@Dari-K

Description

@Dari-K

This feature request is for @angular/forms

Currently there's no ng-submitted class added to form elements after submit. As far as I can tell this class did exist in angularJS. This complicates forms that are relying on classes like ng-touched and ng-invalid to add error styling. For example if a form element is required, but not touched before the form is submitted, then a style using .ng-touched.ng-invald will not be matched. This means you either need to mark the form/elements as touched manually on submit, or add a class binding yourself to track when the form has been submitted. You'll have to do this on every form in your project, making it likely that you may forget to do it on occasion, and your error styling won't kick in under certain circumstances. You could disable form submission when the form is invalid, but that doesn't seem ideal, especially on larger forms as the user may have missed some form elements that are required, and there won't be any error styling to indicate this, because the element hasn't been touched.

Opened a new issue because this feels different from #20477

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions