<select class="invalid">...</select>
After initialisation the wrapper div should have the class "invalid".
A wrapper div is created without the "invalid" class, resulting in the wrong style being applied.
Apply the "invalid" class to the wrapper when the original select has the "invalid" class on initialisation. The CSS is already present so I'm guessing it's a bug.
Use the classes option instead of adding the class directly to the select element
It would be great if both ways work.
Really would appreciate if that would work. Using a template engine it makes much easier to have consistent handling on all form elements. It's a hack to use JS for that, especially if you want to dynamically set that class (since you need to provide the classes option on initialization).
I took the liberty of creating a fix: #5584
It makes more sense to use the classes option imo.
I think that depends on the way you use it. I use a PHP framework that automatically creates the HTML for the form inputs including pre-filled data, validation errors etc. Adding the "invalid" class in the
Either way, this fix won't break using the javascript way, it just adds a bit more functionality.
@Dogfalo can we get your opinion on this pls?
Custom jQuery and vanilla JS code I've created to fix this issue for my own projects.
Both work like a charm, but it would be fantastic to get proper validation similar to this on the actual framework source code.
Most helpful comment
It would be great if both ways work.