Closed jeroenk22 closed 8 years ago
As you can see the form-group div of the Select2 widget has a has-success
class, but the span inside it keep ahas-error
class..
This is more a Yii validation behavior that sets the has-success
and has-error
Bootstrap states and not a Select2 plugin issue.
Having said that, Yii client validation has a problem for such jquery plugins and this routine does not understand the Select2 markup like normal inputs.
I have provided an enhancement specific to Select2 widget that will fix it for most use cases.
However for advanced cases like AJAX based validations in Select2 - you need to write the JS code and trap this in the right event (e.g. on form submit button click ) and use the initS2Change
JS method available with this Select2 widget extension and pass the $("#your-select2-id")
as a parameter to the above method.
Hi Kartik,
I'm using your
DetailView
widget inside a modal and i'm trying to send the form using ajax. Now there's a problem. When I clear aSelect2
field (multiple) and try to submit the form there's a validation error. So far this is expected behaviour. But when I then select some values it should pass the validation, but unfortunately, it doesn't. The field gets a green border but still keeps thehas-error
class somehow. The class disappears when the field gets focus again. This only happens with theSelect2
widget as far as I can see.My controller:
My JQuery:
Screenshot: