我想以“阿拉伯语”显示验证消息,所以我使用了:
$this->form_validation->set_message('required','my message');
但这只会返回“我的消息”。
有没有一种方法可以为我的消息中的每个字段添加标签,看起来就像这样。
label "my message"
例子:
<input type="text" name="field1">
<input type="text" name="field2">
输出:
field1 my message
field2 my message
在用户指南中。
如果您在错误字符串中包含%s,则在您设置规则时,它将替换为您在字段中使用的“人工”名称。
https://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#settingerrors
您可以将代码更改为此。
$this->form_validation->set_message('required','%s my message');
然后,它将使用您在验证规则中设置的文件名。
或者,您可以翻译字段名称;
https://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#translatingfn
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句