johannesjo / ng-fab-form

Convenient forms for Angular with no extra markup? Fabulous!
https://johannesjo.github.io/ng-fab-form
MIT License
172 stars 25 forks source link

add class to form, when submit was attempted #53

Closed philipkueng closed 9 years ago

philipkueng commented 9 years ago

Is there a way to set the border of a inputbox after I hit the submit button? Your example just handles the leave- and enter events

johannesjo commented 9 years ago

What do you want to achieve with that? Only show the border only after (unsuccessful due to invalid form-fields?) submission?

philipkueng commented 9 years ago

Exactly. In your example you only show the red border when you leave the inputbox. I want to show the red border when the input is invalid

johannesjo commented 9 years ago

Well, there is unfortunately no class added for that yet. But you could do it like this:

<form name="blaForm"
          ng-class="{'your-parent-form-tried-submit-class': blaForm.$triedSubmit}>
</form>

And then do something like

.your-parent-form-tried-submit-class input.ng-invalid{
     border: 1px solid red;
     // or whatever your error styles should be for inputs
}
johannesjo commented 9 years ago

I think this feature is not too imortant. If someone really needs it, feel free to reopen.