Topic: Reset MDBSelectInput
Justin Martin asked 5 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 answered 5 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>
Justin Martin answered 5 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...)
Jakub Chmura staff premium answered 5 years ago
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
Closed
This topic is closed.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Closed
- User: Free
- Premium support: No
- Technology: MDB React
- MDB Version: 4.27.0
- Device: PC
- Browser: Brave
- OS: Windows 10
- Provided sample code: No
- Provided link: No