我的问题是比较验证无法正常工作。如果我的min_bid_amount = 100
和min_buy_amount=1000
正在运作。但是min_bid_amount = 500
和min_buy_amount=1000
会出现问题。它还给了我错误信息。
这是我的模型规则
public function rules()
{
return [
[['min_bid_amount','min_buy_amount'], 'number'],
['min_buy_amount', 'compare','compareAttribute'=>'min_bid_amount','operator'=>'>',
'message'=>'Buying amount should be bigger than bid amount'],
[['auction_start_date', 'auction_end_date', 'created'], 'safe'],
[['id_product','min_bid_amount','min_buy_amount'], 'required']
];
}
非常感谢任何帮助。我认为JS不会将其转换为int类型值。那我该怎么办呢?
答案 0 :(得分:6)
您应该将type验证更改为number
:
['min_buy_amount', 'compare','compareAttribute'=>'min_bid_amount','operator'=>'>',
'message'=>'Buying amount should be bigger than bid amount', 'type' => 'number'],