在React Admin中设置最大表单字段长度

发布于 2025-01-26 04:29:59 字数 708 浏览 3 评论 0原文

是否有某种方法可以在a simpleform“> simpleform”>内部设置一个字段。 href =“ https://www.npmjs.com/package/reaeact-admin” rel =“ nofollow noreferrer”> react-admin 限制用户可以输入该字段的字符数量?

基于 docs ,React-Admin框架本身似乎不包含此功能。有验证当用户键入太多字符时,可以显示错误的功能,但显然显然是没有内置的方式来限制键入的字符数。鉴于此,有人是否通过其他方式实现了这一目标?

例如,假设“状态”字段的有效值仅是“ a”,“ b”或“ c”。在使用React-Admin时,如何将表单字段仅接受1个字符?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彻夜缠绵 2025-02-02 04:30:00

这与Adv-Admin无关,但是您可以去:

// react-admin / MUI
<NumberInput inputProps={{ maxLength: 1 }} source="my_source" />

//HTML
<input type="number" maxLength=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 />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文