'Set maximum form field length in React Admin
Is there some way to set a field in a SimpleForm within React-Admin to limit the number of characters a user can type into that field?
Based on the docs, the React-Admin framework itself does not appear to contain this functionality. There is validation functionality to show an error when the user types too many characters, but apparently no built-in way to limit the number of characters typed. Given this, has anyone achieved this via other means?
For example, say the valid values for a 'Status' field are only 'A', 'B' or 'C'. How, while using React-Admin, would you limit that form field to accept only 1 character?
Solution 1:[1]
This is not strictly related to react-admin, but here you go:
// react-admin / MUI
<NumberInput inputProps={{ maxLength: 1 }} source="my_source" />
//HTML
<input type="number" maxLength=1 />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | WiXSL |