问题描述
根据,%s将被字段名称替换
Based on the documentation, %s will be replaced by field name when setting error messages.
有一种方法可以在字符串中包含多个%s,并以不同的方式定义它们?
Is there a way to have multiple %s in the string and define them differently?
推荐答案
beforehand with the extra variables already populated.
通过 core / MY_form_validation.php
It might be interesting to extend the form validation class via core/MY_form_validation.php
and work this functionality in. Unfortunately this line is contained in the main function _execute
which is very big and messy, and from looking at it now, you'd need to overload some other functions as well. I started to write an example but it actually looks like a chore. You might be better off using:
$this->form_validation->set_message('rule_name', 'Your custom message here');
有关设置错误消息的更多信息:
More on setting error messages: http://ellislab.com/codeigniter/user_guide/libraries/form_validation.html#settingerrors
这篇关于Codeigniter表单验证 - 是否有一种方法来定义多个不同的%s设置错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!