Skip to content

Pristine option does nothing #680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dorinniscu opened this issue May 10, 2016 · 3 comments · Fixed by #771
Closed

Pristine option does nothing #680

dorinniscu opened this issue May 10, 2016 · 3 comments · Fixed by #771

Comments

@dorinniscu
Copy link

dorinniscu commented May 10, 2016

I tried sf-options="{ pristine: {errors: false, success: false}}".

It comes in scope.options but the options are ignored. It still validates the input no matter if it is pristine or not.

I did a fix but I find it more like a workaround.

'has-error': form.disableErrorState !== true && hasError() && !ngModel.$pristine, 'has-success': form.disableSuccessState !== true && hasSuccess() && !ngModel.$pristine

@Anthropic
Copy link
Member

Could you please make a plunker or gist to demonstrate, it would help us a lot?

@dorinniscu
Copy link
Author

dorinniscu commented May 11, 2016

I added a demo: http://plnkr.co/edit/lYUgSKaW72vCm82G2dg1?p=preview

I set the pristine option according to https://github.com/json-schema-form/angular-schema-form/blob/development/docs/index.md.

The name is prefilled and is validated from the beginning. It is ignoring the pristine option.

@dorinniscu
Copy link
Author

Removing "|| !scope.ngModel.$isEmpty(scope.ngModel.$modelValue)" will fix the problem without using the global option.

scope.hasSuccess = function() { 
    if (!scope.ngModel) { 
        return false; 
    } 
    return scope.ngModel.$valid && 
    (!scope.ngModel.$pristine || !scope.ngModel.$isEmpty(scope.ngModel.$modelValue)); 
}; 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants