angular-xeditable
angular-xeditable copied to clipboard
Use Angular's built-in validations
Is it possible to use Angular's built in validations (ng-pattern, ng-minlength, etc) instead of performing them manually in a custom validation method in the onbeforesave
attribute?
I would like to disable the form's save button using rowForm.$invalid
but for some reason it is not working.
<tr ng-repeat="user in users">
<!-- row inputs -->
<td>
<span editable-text="user.email" e-name="email" e-form="rowForm" e-required>
{{user.email}}
</span>
<!-- use my own custom validation messages -->
<span class="help-block" ng-show="rowForm.email.$dirty && rowForm.email.$error.required">required</span>
</td>
<!-- row form -->
<td>
<form editable-form name="rowForm" onbeforesave="save($index, $data, user.id)" ng-show="rowForm.$visible" class="form-buttons form-inline" shown="inserted == user" novalidate>
<!-- disable button if form is invalid, doesn't work -->
<button type="submit" ng-disabled="rowForm.$waiting || rowForm.$invalid" class="btn btn-primary btn-sm">
<span class="fa fa-save"></span>
Save
</button>
<a type="button" ng-disabled="rowForm.$waiting" class="btn btn-default" ng-click="rowForm.$cancel()">
Cancel
</a>
</form>
<a class="btn btn-info btn-sm" ng-click="rowform.$show()" ng-show="!rowForm.$visible">
Edit
</a>
</td>
</tr>
Would also be useful to use the $pristine and $dirty properties of the form for example to not trigger an update call if the form has not changed.
Are there any updates on this issue?
Pull requests are welcome :)