gpt4 book ai didi

yii - 最小长度规则不接受 Yii 中的消息

转载 作者:行者123 更新时间:2023-12-04 22:08:10 26 4
gpt4 key购买 nike

Yii中我的模型规则函数中的以下代码

public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('mail, firstname, lastname, number, question, time', 'required','message'=>'{attribute} نمی تواند خالی باشد'),
array('status', 'numerical', 'integerOnly'=>true,'message'=>'{attribute} فقط مقادیر عددی مجاز است'),
array('mail, firstname, lastname, number', 'length', 'max'=>45,'message'=>'حداکثر طول {attribute} ۴۵ کارکتر می باشد'),
array('question','length','min'=>10,'message'=>'حداقل طول سوال ۱۰ کارکتر می باشد'),
array('mail','email','message'=>'ایمیل وارد شده حقیقی نمی باشد'),
array('time','unsafe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, mail, firstname, lastname, number, question, time, status', 'safe', 'on'=>'search'),
);
}

所有消息都正常工作,除了我定义的最小长度
array('question','length','min'=>10,'message'=>'حداقل طول سوال ۱۰ کارکتر می باشد'),

它总是返回 Yii 的默认值,这意味着 پرسش 太短(最少 10 个字符)。

最佳答案

message属性被使用 only当字段不是由 is property 指定的某个确切长度时.对于自定义最小长度消息,请使用 tooShort property :

array('question','length','min'=>10,'tooShort'=>'حداقل طول سوال ۱۰ کارکتر می باشد'),

关于yii - 最小长度规则不接受 Yii 中的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13929254/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com