Materialize: [select] invalid class not applied to select-wrapper

Created on 8 Jan 2018  路  7Comments  路  Source: Dogfalo/materialize

Expected Behavior

<select class="invalid">...</select>

After initialisation the wrapper div should have the class "invalid".

Current Behavior

A wrapper div is created without the "invalid" class, resulting in the wrong style being applied.

Possible Solution

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.

Your Environment

  • Version used: 1.0.0-alpha.3

Most helpful comment

It would be great if both ways work.

All 7 comments

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