Enable Save buttons in editable forms when form is $invalid

Issue #392 resolved
Brian Lewis repo owner created an issue

The reason is that the default handler for save should itself check for $invalid, then $setSubmitted and abort if form.$invalid

By setting the form status to submitted, we can display error messages that may not otherwise get made visible in the UI.

Comments (3)

  1. Brian Lewis reporter

    The behaviour described above is implements in ComponentEditController Save method - all editing dialogs should use controller that derive from the base class.

  2. Brian Lewis reporter

    On an md-input-container, you can use md-is-error attribute for an expression to control when the md-input-container goes into "error state". Documentation says the default is when the control is "teouched and invalid"

    Not quite - control also goes into error state when the form is submitted.

    Interestingly, resetting touched and submitted using the undo changes button does not take the control back out of error state - so after Undo, the error message remains.

    The showErrors method on componentEditController emulates the default behaviour just described. Assigning this to md-is-error makes no difference, but putting this on ng-messages like so:

    <div ng-messages="vm.modelForm.trYear" ng-show="vm.showErrors('trYear')">
    

    makes the errors go away on Undo.

    So for now, we'll just leave the default behaviour on error visibility.

  3. Log in to comment