Topic: Reset MDBSelectInput

Justin Martin free asked 4 years ago


Hello,

I try to find a way to reset MDBSelectInput value. I tried to change the selected prop but it can not affect the input, because as doc explained : the selected prop is default value. So useless if a value is previously selected by user.

If you have any idea how to do it ?


Justin Martin free answered 4 years ago


A way to do is to have a select HTML element in a form and when you want to reset the select, use the native function reset() of the form (as exemple with a ref). (I tried with MDBSelect instead of select HTML, but it doesn't work with this one...)

Exemple works :

<form ref={this.formRef}>
    <select className="browser-default custom-select">
        <option value="">Select element</option>
         ...
     </select>
</form>

Jakub Chmura staff commented 4 years ago

Nice to hear that you found a solution!

Best, Kuba


Jakub Chmura staff answered 4 years ago


Hi @Justin Martin

If you want to control a select input you need to use Controlled select. MDBSelectInput is a part of an uncontrolled select component.

You can read more about this component in an API tab on the select documentation page:

I will report a problem with the "version" field to our team.

Best, Kuba


Justin Martin free answered 4 years ago


ps : in your support's form the "version" field is bugged : sometimes we can't set value (and can't valid the form...)


FREE CONSULTATION

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

Status

Closed

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.27.0
  • Device: PC
  • Browser: Brave
  • OS: Windows 10
  • Provided sample code: Yes
  • Provided link: No