Skip to content
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

Option to have .is-invalid (or custom class) applied to the form-control when form is invalid #144

Open
not-a-doctor-stromberg opened this issue Feb 21, 2019 · 4 comments

Comments

@not-a-doctor-stromberg
Copy link

Would it be possible to put a boolean on the component that apply the .is-invalid (or some other custom class) to the form-control element if the associated Angular FormControl is invalid? This would allow the following bootstrap rule to apply:

.was-validated .form-control:invalid, .form-control.is-invalid, .was-validated
.custom-select:invalid,
.custom-select.is-invalid {
  border-color: #dc3545;
}

As is, I am left creating a style like so to replicate the above rule:

.ng-invalid>div.ngx-select>div>div.form-control {
    border-color: $danger !important;
}

I can open an issue against the ng2-select component if you prefer -- I'm not sure if this is regularly updated from that or not :)

Thanks for the component though!

@optimistex
Copy link
Owner

@BloodChiefStromberg Unfortunately I am too busy and can not promise to solve it in soon. But, you can make a fix and make a pull request. I'll check and release it.

@not-a-doctor-stromberg
Copy link
Author

I am in a similar boat :) I'll let you know if I find the time to make the PR.

Thanks again!

@falco442
Copy link

I'm trying to make it, but I don't see the @input formControl, the one that I use to set the component! How the component see formControl???

@optimistex
Copy link
Owner

@falco442 Check this:

export class NgxSelectComponent implements INgxSelectOptions, ControlValueAccessor, DoCheck, AfterContentChecked, OnDestroy {

It implements the interface ControlValueAccessor:
https://angular.io/api/forms/ControlValueAccessor

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

No branches or pull requests

3 participants