Codeigniter的验证类是否支持同一页面上的多个表单?

发布于 2025-01-01 14:04:06 字数 121 浏览 0 评论 0原文

任何人都可以确认 Codeigniter 的验证类不支持同一页面上的多个表单,特别是当表单共享“名称”字段时?

从我读过的帖子来看似乎就是这种情况,只是想知道是否是这样——以及是否有任何巧妙的解决方法?非常感谢。

Can anyone confirm that Codeigniter's validation class doesn't support multiple forms on the same page, especially when the forms share 'name' fields?

That seems to be the case from the posts I've read, just wondering if it is -- and if there are any ingenious workarounds? Much thanks.

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

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

发布评论

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

评论(1

战皆罪 2025-01-08 14:04:06

啊,有趣的问题。无法直接从提交该信息的表单的 POST 数据中获取数据。除非您对字段名称进行“命名空间”,否则您可能无法在同一页面上使用多个经过验证的表单。

另一种方法可能是存储特定于该表单的隐藏字段,并扩展 Form_validation 类以仅显示与该表单相关的错误。

但是,重命名/命名字段会容易得多。也许也更可持续。

Ah, interesting issue. There's no way to derive directly from POST data which form submitted that information. Unless you "namespace" the field names, you're probably out of luck with multiple validated forms on the same page.

Another approach might be to store a hidden field specific to that form, and extend the Form_validation class to show errors related to that form only.

However, it would be much easier just to rename/namespace your fields. Probably more sustainable too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文