@material-ui/core/Select
does not allow for a required
attribute like @material-ui/core/TextField
Should be able to add required
attribute to the <Select>
input and it should:
*
to labelrequired
attribute to the rendered <input>
tagCurrently no support for required
attribute on <Select>
tags
https://codesandbox.io/s/qx4x1w8qlj
<Select>
input with required
attributeWould like <Select>
inputs to act like <TextField>
inputs to make UI consistent
| Tech | Version |
|--------------|---------|
| Material-UI | v1.0.0 |
| React | v16.3.2 |
| browser | Chrome |
@oliviertassinari looks like the non-native solution uses a type=hidden
input so the required validation won't really run unfortunately. Attempting to change it to type=text
in inputProps
results in the following error:
Warning: Failed prop type: You provided a
value
prop to a form field without anonChange
handler.
@mciparelli If you are looking for the native require validation logic, use the native implementation of the select.
Well it's a shame because it would be nice to be able to still have the chance to use the custom select look and feel without losing the HTML5 validation.
@mciparelli Let us know if you find a way to change the implementation to get this done. But I have some doubt that we can achieve it.
@t-lock The inputRef
prop should solve your issue.
Most helpful comment
Well it's a shame because it would be nice to be able to still have the chance to use the custom select look and feel without losing the HTML5 validation.