Missing data-mdb-placeholder css class


Topic: Missing data-mdb-placeholder css class

vgoenka pro premium asked 2 months ago

Expected behavior https://mdbootstrap.com/docs/standard/forms/select/#section-select-with-placeholder

Expected to find data-mdb-placeholder class as per the URL above.

Actual behavior

Looked at both 3.1.0 and 3.2.0 but don't see this class.

Resources (screenshots, code snippets etc.)

The documentation on the web should clearly annotate which version these things are introduced in - or perhaps there should be version specific documentation. This is quite frustrating.


Grzegorz Bujański staff commented 2 months ago

What do you mean you don't see this class? Does the attribute: data-mdb-placeholder work for you? This attribute has not been added in the meantime. It has been available since version 1.0.0-alpha2 in which we added the select component.


vgoenka pro premium commented 2 months ago

The attribute didn't work when I tried. (my bad about calling it 'class' in my comment above).

I'm only including mdb.min.css and mdb.min.js. Do I need to include any other file?


Grzegorz Bujański staff answered 2 months ago

When creating the select component, we made sure that it works in the same way as the native select. Therefore, in this case, you cannot set up a placeholder this way. This will only work for Multiselect. You can add an option with an empty value and selected attribute. I also suggest adding a hidden attribute so that it doesn't show up in the options list. This will make select appear as if it had a placeholder. Here's an example: https://mdbootstrap.com/snippets/standard/grzegorz-bujanski/2862444


Please insert min. 20 characters.