Codeigniter的验证类是否支持同一页面上的多个表单?
任何人都可以确认 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,有趣的问题。无法直接从提交该信息的表单的 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.