codeigniter 打印表单特定的验证错误
我在一个页面上有 2 个表单,例如:“create_user”和“update_user”,我想在表单上方显示特定于每个表单的验证错误。我的意思是,我想在其上方显示“create_user”表单的验证错误,以及“update_user”的验证错误。
现在,如果我提交更新,两个表单上方都会显示表单错误。 有没有类似的东西
<? echo validation_errors("create_user"); ?>
I have 2 forms on a page eg: 'create_user' and 'update_user' i want to show validation errors specific to each form just above the form. i mean, i want to show validation errors for 'create_user' form just above it and same for 'update_user'.
Right now if i submit update, form errors are showing above both of the forms.
is there something like
<? echo validation_errors("create_user"); ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以执行以下操作:
类似的操作应该适用于显示基于多种表单的错误。希望有帮助
You could do something like:
Something like that should work for showing errors based on multiple forms. Hope it helps
最简单的方法是这样的:
validation_errors()
您可能可以以某种方式扩展验证类来执行您所要求的操作,但这将是一个非常具体的实现,并且在框架中几乎没有用(这就是为什么 CI 默认情况下“不知道如何”执行此操作)。使用扩展类所增加的复杂性可能会抵消不简单地在视图中使用基本逻辑的任何好处。
Simplest way is this:
validation_errors()
in the correct locationYou could probably extend the validation class somehow to do what you're asking, but it would be a very specific implementation, and hardly useful in a framework (which is why CI doesn't "know how" to do this by default). The added complexity of working with the extended class would likely counteract any benefit of not simply using basic logic in the view.