[Forms] Add validation classes

Add classes for required, valid, and invalid, based on
form state and on arguments passed into the form.
WTD-530.
This commit is contained in:
Victor Woeltjen
2014-11-26 13:15:12 -08:00
parent b31b4770d1
commit ede3e4f31e

View File

@@ -6,9 +6,13 @@
{{section.name}} {{section.name}}
</div> </div>
<div class="form-section"> <div class="form-section">
<div ng-repeat="row in section.rows" <ng-form name="mctFormInner" ng-repeat="row in section.rows">
class="form-row validates" <div class="form-row validates"
ng-class="{ required: row.required }"> ng-class="{
req: row.required,
valid: mctFormInner.$dirty && mctFormInner.$valid,
invalid: mctFormInner.$dirty && !mctFormInner.$valid
}">
<div class='label' title="{{row.description}}"> <div class='label' title="{{row.description}}">
{{row.name}} {{row.name}}
@@ -19,7 +23,7 @@
</div> </div>
<div class='controls'> <div class='controls'>
<div class="wrapper" ng-if="row.control"> <div class="wrapper" ng-if="row.control">
<ng-form name="mctFormInner">
<mct-control key="row.control" <mct-control key="row.control"
ng-model="ngModel" ng-model="ngModel"
ng-required="row.required" ng-required="row.required"
@@ -27,7 +31,6 @@
structure="row" structure="row"
field="row.key"> field="row.key">
</mct-control> </mct-control>
</ng-form>
</div> </div>
<div ng-repeat="item in row.items" class="validates"> <div ng-repeat="item in row.items" class="validates">
<ng-form name="mctFormInner"> <ng-form name="mctFormInner">
@@ -40,8 +43,8 @@
</ng-form> </ng-form>
</div> </div>
</div> </div>
</div> </div>
</ng-form>
</div> </div>
</span> </span>
</div> </div>