Select show placeholder even if there are options pre-select


Topic: Select show placeholder even if there are options pre-selected

wwu22 asked 5 years ago

Expected behavior

Select should show pre-selected option if placeholder attribute is set.

Actual behavior

Select show placeholder even if there are options selected.

Resources (screenshots, code snippets etc.)


Krzysztof Wilk staff answered 5 years ago

HI!

Select doesn't have placeholder attribute. But you can do placeholder by yourself :D Sample code should look like this:

<select class="mdb-select md-form">
    <option value="" disabled selected>Choose your option</option>
    <option value="1">Option 1</option>
    <option value="2">Option 2</option>
    <option value="3">Option 3</option>
 </select>

First option is your placeholder. It value should be empty and it should have disabled and selected attributes. Between <option></option> tags you have to put your placeholder text.

And voila! You have your default option, that can't be selected second time, when you choose another.

You can see how our material select works here: https://mdbootstrap.com/docs/jquery/forms/select/#basic


wealthtechs pro premium priority commented 4 years ago

You have data-placeholder option present on your select documentation and doesn't works, the placeholder is showed instead selected value


Krzysztof Wilk staff commented 4 years ago

Oh, now I see. I added task to our board, so we'll fix it soon, thanks for your report :)


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.16.0
  • Device: MacBook
  • Browser: Chrome
  • OS: MacOS High Sierra
  • Provided sample code: No
  • Provided link: No
Tags